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.

Reply via email to