Hi,
at Syncope we had this migration from Hibernate to OpenJPA at the time of incubation, and we also had to face similar issues. FYI we are now on OpenJPA since 2011 and we have never been regretting such a choice that was initially dictated by licensing.

Coming to your question, we also rely on Spring ORM: see configuration [1][2], allowing no persistence.xml, and a very tiny orm.xml [3] - I know it's somewhat involved, but we do have to support multi-tenancy, hence multiple persistence units, plus multiple DBMSes.

Also, we do entity enhancement at build time [4] via Maven, at the sole price of a simple persistence.xml [5] to be used only there.

Finally, we provide a tweak for Spring ORM to look for JPA entity classes from multiple JARs in the classpath - see [6].

Please have a look at let me know if there is anything unclear.

Regards.

[1] https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa/src/main/resources/persistenceContext.xml [2] https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa/src/main/resources/domains/MasterDomain.xml [3] https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml [4] https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa/pom.xml#L143-L174 [5] https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa/src/main/resources/persistence-enhance.xml [6] https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/MultiJarAwarePersistenceUnitPostProcessor.java

On 05/05/19 19:32, Ebenezer Graham wrote:
Hello Devs,

I am an Apache Fineract CN contributor currently working on migrating the
project's ORM from Hibernate to OpenJPA (more on the issue
<https://jira.apache.org/jira/projects/FINCN/issues/FINCN-2?filter=allopenissues>
).

https://github.com/ebenezergraham/fineract-cn-postgresql/commit/c10a1e77c3a290c1faa671621baf6c6037ba260a

I want to know how to dynamically enhance entity classes for each
microservice's entity without having to hardcode the configuration in an
XML.

The aim is to do the enhancement with spring or gradle. I would appreciate
it if someone could share their experience on how to handle this (a better
way of doing this https://openjpa.apache.org/enhancement-with-maven.html
with gradle, a plugin or spring boot autoconfiguration).

A brief overview, the project has a PostgreSQL library and a provisioner
microservice which provides persistence functionalities to 13 other
microservices. The goal is to configure the enhancement once in the
PostgreSQL library - a one size fits all approach.

The above issue has led to this error(full log here:
https://pastebin.com/kGQu4qLH)

Error creating bean with name 'jpaMappingContext': Invocation of init
method failed; nested exception is <openjpa-2.4.1-r422266:1730418 fatal
user error> org.apache.openjpa.util.MetaDataException: The type "class
org.apache.fineract.cn.customer.internal.repository.PortraitEntity" has not
been enhanced.

*Regards,*

*Ebenezer Graham*


--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/

Reply via email to