|
From: <jue...@we...> - 2004-07-17 17:59:23
|
Oh, I didn't notice this. I was just wondering because JdbcTemplate's =
update(PreparedStatementCreator, List) method still takes a List for =
generated keys... Shouldn't it use a KeyHolder too? KeyHolder and co =
would have to reside in the core package then, I guess, because =
jdbc.core.support is intended to refer to jdbc.core but not the other =
way round. jdbc.support would be OK too, provided that KeyHolder does =
not depend on jdbc.core.
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Thomas Risberg
Gesendet: Sa 17.07.2004 19:31
An: spr...@li...
Betreff: Re: [Springframework-developer] Generated keys support
I added a KeyHolder interface and a GeneratedKeyHolder class (in
jdbc.support). They are used by the SqlUpdate.update(Object[],
KeyHolder) method.
Here is an example:
SqlUpdate su =3D new SqlUpdate(dataSource, "insert into Show2
(name) values(?)");
su.declareParameter(new SqlParameter("name", Types.VARCHAR));
su.setReturnGeneratedKeys(true);
su.setGeneratedKeysColumnNames(new String[] {"id"}); //this has
no effect for MySQL only DB2
su.compile();
Object[] val =3D {"Sven"};
KeyHolder kh =3D new GeneratedKeyHolder();
int updateCnt =3D su.update(val, kh);
int myKey =3D kh.getKey().intValue();
System.out.println("Key: " + myKey);
List myKeys =3D kh.getKeyList();
System.out.println(myKeys);
Direct JdbcTemplate use would look like:
KeyHolder kh =3D new GeneratedKeyHolder();
int rowsAffected =3D
getJdbcTemplate().update(newPreparedStatementCreator(args),
kh.getKeyList());
Thomas
j=FCrgen h=F6ller [werk3AT] wrote:
>Thomas,
>
>We discussed changing the List argument for generated keys into a =
GeneratedKeysHolder class or the like, for easier access to a single =
generated key (the typical use case). If we change that, we should do so =
before 1.1 RC1, even if this means having 1.1 RC1 mid or late next week =
rather than on Monday.
>
>Juergen
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by BEA Weblogic Workshop
>FREE Java Enterprise J2EE developer tools!
>Get your free copy of BEA WebLogic Workshop 8.1 today.
>http://ads.osdn.com/?ad_idG21&alloc_id=10040&op=3Dclick
>_______________________________________________
>Springframework-developer mailing list
>Spr...@li...
>https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
>=20
>
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=3D4721&alloc_id=3D10040&op=3Dclick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|