We are using Spring HibernateTemplate class for hibernate operation. I need to execute a query with in clause and setting the options for in using an arrayList. For that i need a org.hibernate.Query object.
String queryStr = "from CertMetadataCfg where metadataId in (:metadataIds)";
Query query=hibernateTemplate.getSessionFactory().openSession().createQuery(queryStr)
query.setParameterList("metadataIds", metadataSet);
but for retrieving Query object we have to open a new session. Why do we need to open a session. and when should we close this session .
HibernateTemplate does the opening and closing of the session handling.
Please check the documentation.
Use findByNamedParam –