Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] @Embeddable and @mapsId

here is one scenario
there are two entity A, B, A has PK class APK including aId, bId, B has BPK
class including aId, bId as well. they have oneToone relationship. Can I use
annotation @MapsId on @OnetoOne relationship on entity B? 

==========================
 // parent entity has simple primary key

    @Entity
    public class A {
       @EmbeddedId APK id;
        ...
		
       
      @OneToOne(optional=false, mappedBy="a", cascade = ALL, targetEntity =
B.class)
      @PrivateOwned
      private B b;
       ...
    } 



    @Entity
    public class B {
       @EmbeddedId BPK id;
        ...
		
       
       @OneToOne(optional = false)
	@JoinColumns({
		@JoinColumn(name="A_ID", referencedColumnName="A_ID"),
		@JoinColumn(name="B_ID", referencedColumnName="B_ID"),
		})
		@MapsId ??????
		private A a;
    }
 
 
  @Embeddable
    public class BPK {
		@Column(name="A_ID")
       int aId name;
	   
	   @Column(name="B_ID")
       long bId; 
    }
======================================
-- 
View this message in context: http://old.nabble.com/%40Embeddable-and-%40mapsId-tp27913035p27913035.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top