[jboss-user] [EJB 3.0] - Re: Relationship Only Saving 1 Child Object

waynebaylor do-not-reply at jboss.com
Sat Nov 10 10:53:46 EST 2007


since you're using the mappedBy attribute your code should look something like:
Order order = ...;
  | OrderLine ol1 = ...;
  | OrderLine ol2 = ...;
  | 
  | ol1.setParentOrder(order);
  | ol2.setParentOrder(order);
  | 
  | Collection<OrderLine> orderLines = order.getOrderLines();
  | orderLines.add(ol1);
  | orderLines.add(ol2);
  | 
  | order.setOrderLines(orderLines);
  | 
  | -----------------
  | //save code
  | em.persist(order); //or em.merge(order)
  | 
  | 

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

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



More information about the jboss-user mailing list