cancel
Showing results for 
Search instead for 
Did you mean: 

How to run Hibernate queries ?

greglenain
Champ in-the-making
Champ in-the-making
Hi,

In order to run Hibernate queries against the repository, I'd like to get access to an Hibernate session from a foundation or JCR client (V1.4).

How to do ?
4 REPLIES 4

greglenain
Champ in-the-making
Champ in-the-making
Nobody knows ?

Is Hibernate really part of the Alfresco project ?

derek
Star Contributor
Star Contributor

org.alfresco.repo.admin.patch.impl.InvalidNameEndingPatch
org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl

greglenain
Champ in-the-making
Champ in-the-making
Do you mean some code like that ?
HibernateNodeDaoServiceImpl hibernateService = (HibernateNodeDaoServiceImpl) context.getBean("nodeDaoServiceImpl");
SessionFactory hibernateSessionFactory = hibernateService.getSessionFactory();
org.hibernate.Session hibernateSession = hibernateSessionFactory.getCurrentSession();

String query = "select_whatever_I_need_to_query";
Iterator results = hibernateSession.createQuery(query).list().iterator();

It does work.

Thanks.

derek
Star Contributor
Star Contributor
Hi,

I had the same pattern in mind i.e. derive from HibernateDaoSupport, otherwise just inject sessionFactory bean directly.

Regards