persistence@glassfish.java.net

Re: Retrive autoincrement value with MySQL connector 5.1

From: kai pupha <kai_kree_at_hotmail.co.uk>
Date: Thu, 26 Jul 2007 02:50:16 +0100

Hi Marina,
Thank you for the link.

I used this:
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)

And now i can retrieve autoincremented ID, but just wonder what if i want to
port my work to different dbms like: Microsoft SQL Server and Access. How
can i do that to access generators? Do you know?

Thank you,
Kreecha


>From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
>Reply-To: persistence_at_glassfish.dev.java.net
>To: persistence_at_glassfish.dev.java.net
>Subject: Re: Retrive autoincrement value with MySQL connector 5.1
>Date: Wed, 25 Jul 2007 16:12:44 -0700
>
>Hi Kreecha,
>
>Does this bug describe your problem:
>https://glassfish.dev.java.net/issues/show_bug.cgi?id=3395
>
>If yes, did you try to call em.flush() before retrieving the value?
>
>thanks,
>-marina
>
>kai pupha wrote:
>>Hi there,
>>
>>I am new and trying Java Persistence using J2SE and found one problem
>>that you may be able to help. I have 2 tables let say: 1) tbCUSTOMER:
>>ID(PK) and Name; and 2) tbORDER: ID(PK), Address and Customer_ID(FK).
>>tbORDER.Customer_ID is a forign key of tbCustomer.ID.
>>
>>When i want to update the foriegn key (tbORDER.Customer_ID) obtained from
>>newly generated value from tbCustomer.ID it just updates NULL value but
>>the rest of the fields are updated successfully.
>>
>>I am using JDK 6, Netbeans M10 with Toplink and MySQL Connector 5.1. Do
>>you know that autoincrement is supported in JPA or how can i work around
>>to obtain a newly generated primary key please?
>>
>>Thank you,
>>Kreecha
>>
>>_________________________________________________________________
>>Watch all 9 Live Earth concerts live on MSN. http://liveearth.uk.msn.com

_________________________________________________________________
The next generation of Hotmail is here! http://www.newhotmail.co.uk