db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Datastore identity strategy
Date Wed, 29 Mar 2006 07:02:32 GMT
Hi Andy,

On Mar 28, 2006, at 10:33 PM, Andy Jefferson wrote:

> Hi Craig,
>
>> Using both identity and sequence makes sense for schema generation
>> where you want the identity strategy (JDO implementation doesn't
>> generate key values) and automatic key generation using the sequence
>> named (JDO implementation generates the trigger and stored procedure
>> to use the named sequence).
>
> JPOX doesn't support creation of trigger/storedproc for using  
> sequences like this
> currently.
> We could just retrieve the value from the sequence and use that in  
> the INSERT
> (which is what we do with strategy="sequence" anyway). Whether the  
> JDO impl uses
> triggers/storedprocs is its decision isn't it ? How would a TCK be  
> able to check
> what the impl was doing ? ;-)

The TCK doesn't require an implementation to generate schema. So the  
only thing you would have to do in case of strategy="identity" is to  
stay out of the database's way. Assume the keys are generated (which  
means that you need to use the getGeneratedKeys method to retrieve  
the keys after an insert operation.
>
>>> So how do you specify MySQL "autoincrement" if you remove this ?
>>> They aren't "IDENTITY" type.
>>
>> It seems that the functionality is identical to IDENTITY as defined
>> by SQL 2003.
>
> Internally JPOX treats "identity" and "autoassign" identically, so  
> this part
> would actually simplify things slightly for us, and causes no issue  
> that I know of.
>
Cool.
>
>
>> I'd say strategy="identity" with no sequence means use the
>> GENERATED ... AS IDENTITY.
>
> Yes, or "autoincrement", or probably "SERIAL" too.
>
>> strategy="identity" with sequence also specified means use a trigger
>> and stored procedure to generate key values.
>
> Yes, but with my comments above.
>
>> strategy="sequence" means use the named sequence explicitly in insert
> statements, as in INSERT INTO EMPLOYEE (ID, NAME) VALUES
> (named_sequence.nextval, ?).
>
> Yes, although the implementation needs to know the value being used  
> so would
> likely do the "nextval" call first and plug the value into the INSERT.

I've confirmed with the JDBC4 spec lead that you can retrieve the  
keys using getGeneratedKeys if you use this strategy.

Craig
>
>
> --
> Andy
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message