Search code examples
javajpaopenjpapersistence.xml

How to detect entities automatically with openJPA?


I'm looking for an entity detection in OpenJPA. That I don't need to declare all entities in the persistence.xml.

Edit: I'm sorry, I forgot to say that I develop a java se app.


Solution

  • Read the Persistent Class List section in the user manual.

    Unlike many ORM products, OpenJPA does not need to know about all of your persistent classes at startup. OpenJPA discovers new persistent classes automatically as they are loaded into the JVM; in fact you can introduce new persistent classes into running applications under OpenJPA.

    • Note: There are a couple restrictions that are documented in the user manual but I left those out to keep this post brief.