Issue #2073: Feature suggestion: auto-detection of entities via persistence.xml extension

Type: Feature RequestVersion: 1.4.0Priority: NormalStatus: ClosedReplies: 1
#1

I am encountering problems (complexities) with EntityManager registration of entities across multiple modules in a multi-module Maven project. I have a  entities under many different paths in many different modules, and frequently evolving/changing.

JPA2 persistence.xml does not seem to have support for wildcards under the <class> field.

Apparently Hibernate has an autodetection extension system: hibernate.archive.autodetection

https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html

Example extension usage in persistence.xml:

<properties>
    <!-- Scan for annotated classes and Hibernate mapping XML files -->
    <property name="hibernate.archive.autodetection" value="class, hbm"/>
    <property name="hibernate.hbm2ddl.auto" value="validate" />
    <property name="hibernate.show_sql" value="true" />
  </properties>

Q1: Would it be possible to introduce such an entity-scanning extension feature in ObjectDB ?

Q2: Does it make any difference to the EntityManager whether one performs compile-time enhancement or runtime enhancement ?

That is, does the enhancement have any effect on entities known to:

entityManager.getMetamodel().getEntities();
#2

Actually ObjectDB has an automatic mechanism for registration of entity classes, which should work unless exclude-unlisted-classes=true is specified in the persistence.xml file.

The classpath root that contains the persistence.xml file and any jar file specified with jar-file in the persistence.xml file (but not the entire classpath) are searched for annotated classes and XML data when you invoke:

    entityManager.getMetamodel().getEntities();

It should work regardless if the classes are enhanced or not.

ObjectDB Support

Reply