I’m working with many classes which are annotated with javax.persistence.Entity and the like. My project is about generating metadata about JPA-annotated classes rather than persistence by itself, so I’m using them as test cases.
Rather than firing up Hibernate or some other JPA provider, I’d like to programatically check – part of my unit tests – that my JPA declarations are indeed valid.
What’s the easiest way of doing that?
Just create the simplest possible
SessionFactoryor whatever EclipseLink or OpenJPA provide behind theEntityManagerFactoryand let them validate it (using some dummy in-memory database, if needed). It’s too complex to reinvent it.For Hibernate this can be done using
Configuration.buildMappings: