|
From: <jue...@we...> - 2004-07-19 09:03:36
|
OK - I think it makes sense to stick to such a uniform approach here. =
I'll give the finished version a try as soon as I can, against MySQL.
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Thomas Risberg
Gesendet: Mo 19.07.2004 00:20
An: spr...@li...
Betreff: Re: [Springframework-developer] Generated keys support
I'd like to wrap this up -
For SqlUpdate - I'm removing update(Object[], List) and leaving
update(Object[], KeyHolder)
For JdbcTemplate - I'm changing update(PreparedStatementCreator, List)
to update(PreparedStatementCreator, KeyHolder)
I'm also moving KeyHolder/GeneratedKeyHolder to jdbc.support package.
I'm comitting these changes tonight.
Thomas
Thomas Risberg wrote:
> We could add an update(PreparedStatementCreator, KeyHolder) method to
> JdbcTemplate - should we get rid of the
> update(PreparedStatementCreator, List) at the same time to keep things
> simpler? This would force the use of the KeyHolder.
>
> Thomas
>
> j=FCrgen h=F6ller [werk3AT] wrote:
>
>> 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.
>>
>> Juergen
>>
>>
>> ________________________________
>>
>> 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:
>>
>>=20
>>
>>> 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
>>
>>
>>
>>
>> -------------------------------------------------------
>> 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
>
>
>
-------------------------------------------------------
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
|