I'm working with Adobe Experience Manager (AEM) 6.4 with Service Pack 1, and the Forms Package. I have a lot of extended Properties/attributes, so I made a Database diagram. I don't want to save all the additional stuff in crx I want to save it in an Oracle database.
The Database diagram is complex, so I want to USE JPA (Hibernate), at minimum. If Spring would help to make it easier to use, than that would be fine for me.
I read a lot that the OSGI is working with blueprint instead of Spring, but you can combine it.
I'm really searching for an good example how to make things work with JPA and a Oracle db.
Adobe is no Help at all, they can't show an example how to work with AEM and JPA/Hibernate/Spring/blueprint.
Can anybody help me to make things working? with AEM and JPA?
I think what I need is:
- persistence.xml (RESOURCE_LOCAL or JTA?)
- Entity classes with Annotation @Entity and other JPA annotations
- Service classes with Transaction control and maybe manager classes to submit to work with the entity classes and get result from queries, maybe I could put it all in the service classes
- hibernate-osgi (dependency)
- ojdbc7 for connection (dependency)
- org.apache.aries.jpa.api (dependency)
But how do I have to make things happen? Nothing works. I even don't know if this is the right way.
should I use blueprint or Spring or both?
I found this Aries thing from apache. http://aries.apache.org And weard different samples that I don't really understand how they work. https://github.com/apache/aries-jpa/tree/master/examples
And some OSGI sample, they look very incomplete for my situation. https://enroute.osgi.org/tutorial/032-tutorial_microservice-jpa.html
So is there anybody with some experience with AEM and JPA?
I've found the solution and made a post here on the site.
https://forums.adobe.com/message/10640295#10640295
I feel like I'm the First Guy on earth which combined AEM with JPA/Hibernate. Now I could check if it's a benefit to work with spring, to operate with the Transactions.
And those two who voted the question down, I'm sure you are from adobe --> thanks, now I feel more expert than you on your own cms, because before my post there was no solution for this problem.
Update: Maven Dependencies. If you have problems with the dependencies you have to Embed them and add the property "Embed-Transitive to true"
let me describe how it is implemented on our project. We are using AEM 6.3 with SP2. We have next dependencies in the root pom.xml:
Then we have the bundle to provide JPA dependencies and the OSGI service that allows to get hibernate Session. The bundle pom.xml
In the bundle we have next service:
implementation:
osgi config for the service:
Configuration for DataSourceFactory apps/myproject-forms/configuration/config.local/org.apache.sling.datasource.DataSourceFactory-localh2.xml:
Also we have the Hibernate config file hibernate.cfg.xml in "resources" folder of the bundle
There are some blog posts describing how to realise JPA persistence in AEM/CQ. In using-jpa-to-write-database-applications-in-an-osgi-container-e-g-felix-or-adobe-aem-cq5 they describe how to setup a JNDI datasource with a PersistenceUnit and how to @Reference a EntityManagerFactory.