« Return to Thread: JPA OneToOne with Primary Key FK Question

JPA OneToOne with Primary Key FK Question

by tch :: Rate this Message:

Reply to Author | View in Thread

I'm having a hard time with a OneToOne with a Primary Key as Foriegn
Key relationship.

The secondary table is not getting the PK set, it's going in as null,
instead of grabbing

Here's the EO's.

Account and AccountDetails

They both share account_id as PK's.

I set the relationships on both sides and persist the account object,
the insert on the account_details fails with a null account_id.

Account
---
public class Accounts extends CreatedByModifiedByBaseEntity implements
Serializable {
        @Id
        @GeneratedValue(generator="ACCOUNT_ID_SEQ",strategy=GenerationType.SEQUENCE)
        @SequenceGenerator(name="ACCOUNT_ID_SEQ",sequenceName="crm.\"ACCOUNT_ID_SEQ\"",allocationSize=1)
        @Column(name="account_id")
        private Long accountId;

        @OneToOne(mappedBy="accountId",cascade=PERSIST)
        private AccountDetails accountDetails;

Account_Details
---
public class AccountDetails extends ModifiedByBaseEntity implements
Serializable {
        @Id
        @Column(name="account_id")
        private Long accountId2;

        @OneToOne
        @PrimaryKeyJoinColumn
        private Accounts accountId;

--
./tch
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

 « Return to Thread: JPA OneToOne with Primary Key FK Question