"echon" wrote : if you know your use-cases lazy-loading is not a big problem. | | If you know exactly what to load use a facade with where the business methods load what you want. Inside the BM use the EJB QueryLanguage like | from User u left join fetch u.companys as c left join fetch c.country where u.login=:login | Problem here is you have to be carefull, if you have more than one left join, because you get a the scalar as result (like in this case where you (can) get the user x times, also if login is unique) | | Another way to do so is to make your faced as Statefully SessionBean (SFSB) with a longrunning PersistentContext. In this you get persistent (not detached) object you can work with. Also here you should do as much as possible with a left join fetch from the associated entities you need in your use-case (one join is better than execute a Select each time - if you have products you don't want a select for each category). | With a SFSB you control the lifecycle of the bean and the persistentcontext. So you have "manually" remove the bean by calling a method annotated with @Remove. | | For SFSB and Extended PersistenceContext read the JBoss EJB 3 Trailblazer. If you a familiar with JSF it is a good idea to have a deep | look at JBoss Seam (first choice for a good web-application). | | Regards | | Peter
Peter, thank you, this really helped. I wasn't aware of the left join fetch option, it solves (most) of my problems and was incredibly simple. I must have been looking in all the wrong places for this information! Thanks again! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3948853#3948853 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3948853 _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
