This is governed by JPA 2 spec section 2.4.1, "Primary Keys Corresponding to Derived Identities". The section contains two examples directly applicable to your problem.
This is governed by JPA 2 spec section 2.4.1, "Primary Keys Corresponding to Derived Identities". The section contains two examples directly applicable to your problem. As described in the spec, there are two ways to represent the child entity's key in this case: @IdClass @EmbeddedId Here's a rough sketch of the EmbeddedId way.
I chose EmbeddedId arbitrarily, but the choice between IdClass and EmbeddedId is significant. You might choose differently. // Child entity's composite primary key @Embeddable public class InstanceNotifyEntityId implements Serializable { Long eaihId; Long userId; } // Child entity @Entity @Table(name="EIF_INST_NOTIFIED") public class InstanceNotifyEntity implements Serializable { @AttributeOverrides({ @AttributeOverride(name="userId", @Column(name="USER_ID")) @AttributeOverride(name="eaihId", @Column(name="EAIH_ID")) }) @EmbeddedId InstanceNotifyEntityId id; @MapsId("eaihId") @ManyToOne InstanceEntity instance; // ... } The parent entity needs one change: the userDetails attribute mappedBy should be "id.
EaihId". I think that's it, but I haven't used entities exactly like this before. Might have missed something... please post if you see errors.
Thanks, this works for the most part. Unfortunately I am not using jpa 2.0 so the @MapsId annotation is not available. I have this working for inserts by removing the cascade relationship from the parent entity userDetails object.So I am required to insert each child element after persisting the parent element, but it is workable for now.
– broschb Jul 26 '10 at 4:06 @broschb What are you using? – Dan LaRocque Jul 26 '10 at 4:26 jpa 1.0 spec. Currently I am required to use jboss 4.2.3, my understanding is jpa 2.0 will not work on this app server, at least not without swapping out a bunch of libraries.
– broschb Jul 29 '10 at 22:14.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.