Hi Michael.
I don“t know about your problem with the dvd store but i would like to give you a tip.
The Lazy loading works only with managed entities. That means that you have to get the entity with the entity manager and use it.
If you have a reference that is persisted but is not attached to a entity manager you have to merge it.
For example.
If you have a Many to many relationship between an entity named Person and a entity named Project.
@Entity
@Name("person")
public class Person implements Serializable {
//id and code
//...
@ManyToMany
private List<Project> projects;
//getters and setters
}
And have an action method that use a person object
public void doSopmething(){
//this.person is a valid reference to a person object in the session for example
// you have to merge it so the entity manager can lazy load the projects.
Person newReferenceToPerson = entityManager.merge(this.person);
//now, use the new object that is sincronized with the database.
// You could rereferenciate the person too.
List<Project> projects =
newReferenceToPerson.getProjects();
//It lazy loads all projects asociated to this person.
}
I hope this helps.
Michel,
Try injecting your persistence context using @In - I believe that lazy loading only works with Seam-managed PC (the one injected via @PersistenceContext is not Seam-managed). Of course, you'll need to setup the SMPC properly as well... (look at examples)
HTH,
Alex
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4084001#4084001
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4084001
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user