Hi ! 

Probably you want to access a relationship property when the entity bean is no 
longer under control of the entity manager (a "detached" entity).

There are two ways around this problem:
a) set the fetch type to "EAGER"
@OneToMany(mappedBy="...", fetch=FetchType.EAGER)
  | public Collection<MyChild> getChilds()
This causes the entity manager to load the child collection when the parent is 
loaded. May be a big performance problem.

b) prefetch your childs when the entity bean is still under entity manager 
control.
Imagine a find method of a session bean:
public MyParent findById (Integer id)
  | {
  |    MyParent parent = this.entityManager.find(MyParent.class, id);
  |    parent.getChilds().size();
  | } 
"parent.getChilds().size();" forces loading of the childen.

Hope this helps

Wolfgang

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

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

Reply via email to