How to use hibernate in CQ6? | Community
Skip to main content
New Participant
April 28, 2016
Solved

How to use hibernate in CQ6?

  • April 28, 2016
  • 17 replies
  • 14038 views

Hi,

I am using hibernate 4.0.1 for CRUD operations upon page replication. For this i have written eventhandler, in handleEvent method i am writing logic to persist page property in database using hibernate.

I am getting class not found error in hibernate. added all dependencies in POM file, showing all jars in classpath too, bundle is deployed successfully and it is in active state. 

hibernate.cfg.xml i have put in src/main/resources folder and added this folder in classpath.

java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

Could anyone please help me to resolve the issue, below piece of code is causing the problem 

Configuration configuration = new Configuration().configure();
            ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(
                    configuration.getProperties()). buildServiceRegistry();
            SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
            Session session = sessionFactory.openSession();

 

Thanks,

Pradeep

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ratna_Kumar

Hi Pradeep,

As Scott stated, the best practice to connect AEM with database is injecting a DataSourcePool.

But Yes, AEM may support hibernate too(http://mvnrepository.com/artifact/org.hibernate/hibernate-osgi), but there is no documentation/community articles related to this topic.

Thanks,
Ratna Kumar.

17 replies

New Participant
August 1, 2018

Hi,

Any luck with Hibernate inside the AEM?

Thanks,

Andrii

smacdonald2008
New Participant
April 28, 2016

Some of the AEM people state: 

they can try out the bundle and see what happens. :)

In theory it should work.

Ratna_Kumar
Ratna_KumarAccepted solution
New Participant
April 28, 2016

Hi Pradeep,

As Scott stated, the best practice to connect AEM with database is injecting a DataSourcePool.

But Yes, AEM may support hibernate too(http://mvnrepository.com/artifact/org.hibernate/hibernate-osgi), but there is no documentation/community articles related to this topic.

Thanks,
Ratna Kumar.

New Participant
April 28, 2016

Thanks Donald. 

smacdonald2008
New Participant
April 28, 2016

It may support Hibernate - however - I am not seeing any community articles or documentation that states it does.

Also - I wanted to know why you were not using DataSoucePool - which is best practice.  You answered my question.

I will check within Adobe to see if anyone has examples (assuming it does). 

I will post back my findings. 

New Participant
April 28, 2016

The problem with data source pool is that we have to write sql queries for all crud operations. In my case we have very complex table structure, so writing sql is very tedious task. If hibernate would have supported in AEM my job will become easy and manageable. I am assuming AEM supports hibernate. Please share some links or examples where hibernate has been used along with AEM.

smacdonald2008
New Participant
April 28, 2016

When working with AEM and databases - the best practice is injecting a DataSourcePool - not using Hibernate. 

WHen using a DataSourcePool - you specify the DB properties in the Felix Console config view. 

See this article for more information: 

https://helpx.adobe.com/experience-manager/using/datasourcepool.html