문제

I'm having the following problem:

  • I'm using Oracle ADF for the view and controller of my app.
  • With OpenSessionInViewFilter, I intercept the request and open an Hibernate's Session, and it is closed as soon as the bean's method finishes.

What I need is to keep the Session opened until the page is rendered, because in my JSP y use the lazy attributes of the object i load from the DB.

For example:

When I enter index.jspx the IndexBean#main() is executed:

public class IndexBean{
    private DBObject myDBObject;
    public String main(){
        this.myDBObject = this.myDAO.loadObjectFromDB();
        return null;
    }
}

in index.jspx I have:

...
<af:inputText value="#{myDBObject.lazyAttribute}" />
...

I'd like that the Hibernate's Session keeps open until the af:inputText is processed.

Is this possible? How?

Thanks in advance

도움이 되었습니까?

해결책

Finally, I solved my problem.

The OpenSessionInViewFilter it was working right.

There was a problem with the <af:table> component I was using... The weird thing was that the <af:table> creates a new request. This new request was closing and creating a new Hibernate Session.

다른 팁

I'd suggest you keep your view decoupled from your model and eliminate the lazy loading. Give the page all the data it needs before it gets rendered. If fetching the additional data is really a big performance hit, then consider re-designing the app to present that data separately.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top