It looks like the EJB3 spec does not support an entity bean with a FK as part 
of its compound PK.  I've managed to find JBoss/hibernate docs which describe 
their work around for the problem, and I've managed to get that to work.
The last hurdle that I can't figure out is how to map the reverse association.  
It looks like the ManyToOne in the Embedded PK isn't actually part of the  
EntityBean and so I can't reference it in the mapped by clause from the 
associated Entity Bean.


Abbreviated table structure is as follows:

tblParent
parentId (PK)
...

tblChild
parentId (FK) (PK)
sequence (PK)
...


Very Abbreviated Entities as follows:

@Entity
public class ParentBean {
  ...
  /** HOW SHOULD I ANNOTATE THIS **/
  @OneToMany(mappedBy="parent")  <-- DOESNT WORK
  @OneToMany(mappedBy="pk.parent") <-- DOESNT WORK
  public Set< ChildBean > getChildren();
  public void setChildren(Set< ChildBean > children);
   ...
}
  

@Entity
@AssociationOverride( name="pk.parent", joinColumns = 
@JoinColumn(name="parent_parentId") )
public class ChildBean {
    @EmbeddedId public ChildPK pk;

}


@Embeddable
public class ChildPK {
    @ManyToOne
    public ParentBean parent;
    public Integer sequence;
}



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972208#3972208

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972208
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to