Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Inserting into a Parent and Child table using IDENTITY


But in general, I would not recommend using IDENTITY as it does not support
preallocation.  Use TABLE or SEQUENCE.

Zarar Siddiqi wrote:
> Hi,
> I have a parent table with an autogenerated primary key and a one to one
> table which is a child thus contains the parent's primary key.
> The partent table entity class has the @GeneratedValue(strategy =
> GenerationType.IDENTITY)
> When I persist the parent using the em.persist(parent) method, it tries to
> insert the child as well which is correct behavior.  However, it doesn't
> have the ID of the parent yet so tries to insert a NULL into the child
> table
> which is wrong.  I'm sure this is a fairly common problem, is there a
> workaround to this?  I know I could get this to work using a different ID
> generation strategy but is it possible to do this using IDENTITY?
> Any help is appreciated.
> Thanks,
> Zarar

--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top