persistence@glassfish.java.net

Re: Retrive autoincrement value with MySQL connector 5.1

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
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