criteria « Session « JPA Q&A





1. Hibernate NullPointerException when using criteria in a EntityMode.DOM4J session    stackoverflow.com

I'm running into a null pointer exception if I try to use the following code:

//Spring JPA entityManager allow us to retriver the underlying session.
org.hibernate.Session session = (org.hibernate.Session)entityManager.getDelegate();
org.hibernate.Session dom4jSession = session.getSession(org.hibernate.EntityMode.DOM4J);

org.hibernate.Criteria c ...

2. Store a Criteria in request.session    forum.hibernate.org

Hi, A user submits a form, we get the count, and in the next step the user can choose to genereate different reports. How can I reuse the criteria. I would like to store the criteria in session and then retrieve the results in the next step. But I am getting sesson is closed! ( even in the same request when ...

3. H3: Criteria instance is tied to a session instance    forum.hibernate.org

Seems like if I create a Criteria from one session, I can not associate with another session from the same SessionFactory. I would like to use it for a web based pageable list, and currenty I have to keep a long session and connect/disconnect it. It were much easier and better if I could open a new session at a new ...

4. Session/Criteria mystery has me stumped    forum.hibernate.org

My problem: A criteria gets me an object. I delete it and add another. Later I run the same criteria and it retreives the object I thought I deleted earlier. Further, the criteria does not return the added object even though it would qualify for the results. All code uses the same session object and as far as I can tell ...

5. closing sessions (using criteria)    forum.hibernate.org

Hello, I'm just trying to retrieve a list of objects from DB, using this code: public boolean isRegistered(String classs, String id) { Criteria criteria = this.getSession().createCriteria(MyObject.class); criteria.add(Restrictions.eq("classs", classs)); criteria.add(Restrictions.eq("id", id)); criteria.setMaxResults(1); List list = criteria.list(); return list; } It returns me "forgot to call close() on your session", and after a certain calls to this method, tomcat freezes. I tried this.getSession().close(), ...