Hello,

Of course you can persist relations in one method.


  | public void persistParent(Parent p)
  | {
  |    ParentEntityBean pBean = new ParentEntityBean(p);
  |    em.persist(pBean);
  |    
  |    List<Child> children = p.getChildren();
  |    Child firstChild = children.get(0);
  |    ChildEntityBean cBean = new ChildEntityBean(firstChild);
  |    em.persist(cBean);
  | 
  |    ParentChildRelationEntityBean pcRelBean = new 
ParentChildRelationEntityBean(pBean,cBean);
  |    em.persist(pcRelBean);
  |    
  | }
  | 

I think you have problem there :

  | 
  | @Entity
  | @Table(name = "kennel_dogs")
  | public class KennelDogsEntity implements Serializable
  | {
  |   private KennelEntity kennelD;
  |   private DogsEntity dogID;
  |   
  |   public KennelDogsEntity() {}
  |   
  |   public KennelDogsEntity(KennelEntity kennelID, DogsEntity dogID)
  |   {
  |     this.kennelID = kennelID;
  |     this.dogID= dogID;
  |   }
  | 
  |   @Id
  |   @ManyToOne(optional=false)
  | //  @JoinColumn(name="dogID")
  |   @JoinColumn(name="dogID", insertable=false, updatable=false)
  |   public DogsEntity getDogID()
  |   {
  |     return dogID;
  |   }
  | 
  |   @Id
  |   @ManyToOne(optional=false)
  | //  @JoinColumn(name="kennelID")
  |   @JoinColumn(name="kennelID", insertable=false, updatable=false)
  |   public KennelEntity getKennelID()
  |   {
  |     return kennelID;
  |   }  
  | 
  |   ... setters ...  
  | }
  | 
  | 

I hope it would be useful.

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3942312


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to