Hi Michael.<br><br>I don“t know about your problem with the dvd store but i would like to give you a tip. <br>The Lazy loading works only with managed entities. That means that you have to get the entity with the entity manager and use it.
<br>If you have a reference that is persisted but is not attached to a entity manager you have to merge it.<br>For example.<br>If you have a Many to many relationship between an entity named Person and a entity named Project.
<br>@Entity<br>@Name("person")<br>public class Person implements Serializable {<br> //id and code<br> //...<br> <br>@ManyToMany<br> private List<Project> projects;<br><br>//getters and setters<br>}<br><br>
And have an action method that use a person object<br><br>public void doSopmething(){<br> //this.person is a valid reference to a person object in the session for example<br> // you have to merge it so the entity manager can lazy load the projects.
<br><br> Person newReferenceToPerson = entityManager.merge(this.person);<br> //now, use the new object that is sincronized with the database.<br> // You could rereferenciate the person too.<br><br> List<Project> projects =
newReferenceToPerson.getProjects();<br> //It lazy loads all projects asociated to this person.<br> <br>}<br><br>I hope this helps.<br><br><br><br><div><span class="gmail_quote">On 9/13/07, <b class="gmail_sendername">
ASavitsky</b> <<a href="mailto:do-not-reply@jboss.com">do-not-reply@jboss.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Michel,<br><br>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)
<br><br>HTH,<br><br>Alex<br><br>View the original post : <a href="http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4084001#4084001">http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4084001#4084001
</a><br><br>Reply to the post : <a href="http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4084001">http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4084001</a><br>
_______________________________________________<br>jboss-user mailing list<br><a href="mailto:jboss-user@lists.jboss.org">jboss-user@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/jboss-user">https://lists.jboss.org/mailman/listinfo/jboss-user
</a><br></blockquote></div><br>