-
1. Re: Close session in view
cosmo Oct 14, 2011 10:18 PM (in response to apamplona78)We can't help you if relevant source code isn't posted. In the mean time may be this can help you
-
2. Re: Close session in view
apamplona78 Oct 19, 2011 11:53 AM (in response to apamplona78)The problem is conceptual, when I use
<h:outputText value="#{entity.objectAttribute.name}"/>
in my XHTML, hibernate do another select of 'objectAttribute' because the 'objectAttribute' is mapped by LAZY. I did not want this, I want the programmer build the HQL's in DAO's instead of let hibernate do this another select.
In order of that I would like to close the hibernate session in Facade layer.
My architecture is XHTML / Controller (ManagedBeans) / Facade / BO / DAO.
This problem is because I have been working in a project that has a big performance problem, we discovered that application do a lot of selects, the programmers did not build a good HQL.
For example, if a build a select like 'from Product' and the Product agregate 'productType' as a lazy object, when the XHTML invoke getProductType the hibernate proxy will do another select to retrieve ProductType, If the main select retrieve 200 records, the total select count will be 201 select because is 1 main select and 1 select from each record in order to retrieve producttype.
But if I build the select like 'from Product p left outer join p.productType' will be only one select with left join.
Could someone help me?
-
3. Re: Close session in view
lvdberg Oct 19, 2011 2:14 PM (in response to apamplona78)Hi,
When the association is mapped Lazy, Hibernate will not read the other entity unless you do a join. If you want the entity also LOADED, you need to add the fetch keyword after the join. This will take care of loading. See the hibernate docs for a full explanation of this feature.
Leo
P.S. this is really a basic Hibernate question, so you should ask there.