tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: Persistence assistence @PrimaryKeyJoinColumn
Date Sat, 19 Jan 2013 07:50:52 GMT
Hi,

You should fwd this question to openjpa list IMO and try to create a
runnable sample instead of pasting the code in a mail (otherwise you'll
need to wait people do it themselves...)
Le 19 janv. 2013 00:12, "avrono" <avron@neuralm.com> a écrit :

> The main issue is with the generated ID`s - I cannot get a unidirectional
> OneToOne relationship working where the id columns of the two tables is
> identical. If I remove the @GeneratedValue annotation from the child table
> I
> can get the persistence to work but with differing id fields. I am using
> MySQL with Primary Key (Auto Increment) on the id fields ...
>
> Does anyone have any ideas ?
>
> In the User class
>
> @Entity
> @Table(name="user")
> //@SequenceGenerator(name = "CUSTOMER_SEQUENCE", sequenceName =
> "CUSTOMER_SEQUENCE", allocationSize = 1, initialValue = 0)
> public class User implements Serializable {
>         private static final long serialVersionUID = 1L;
>
>         @Id
>          @GeneratedValue(strategy=GenerationType.IDENTITY)
>         private int id;
>
>         @OneToOne(cascade={CascadeType.ALL})
>         @PrimaryKeyJoinColumn(name="id", referencedColumnName="id")
>         //@JoinColumn(name="id", referencedColumnName = "id")
>         private Usergroup usergroup;
>
>
> In the usergroup
>
> @Table(name="usergroup")
> public class Usergroup implements Serializable {
>         private static final long serialVersionUID = 1L;
>
>         @Id
>         // @GeneratedValue(strategy=GenerationType.IDENTITY)
>         private int id;
>
>
> ......
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Persistence-assistence-PrimaryKeyJoinColumn-tp4660307p4660308.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message