[
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
|
See,
http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Child.27s_id_is_not_assign_from_parent_on_persist.
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
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Inserting-into-a-Parent-and-Child-table-using-IDENTITY-tp21965147p21975799.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.