Search code examples
javahibernatejpahbm2ddl

How to disable sql creation for JPA entity classes


We have some JPA entity classes which are currently under development and wouldn't want them as part of the testing cycle. We tried commenting out the relevant entity classes in META-INF\persistence.xml but the hbm2ddl reverse engineering tool still seems to generate SQL for those entities. How do I tell my code to ignore these classes? Are there any annotations for these or should I have to comment out the @Entity annotation along with my changes in persistence.xml file.


Solution

  • JPA automatically scans your classpath for entities. So one option, as you say, is to remove the @Entity annotation. Another option is to use <exclude-unlisted-classes>true</exclude-unlisted-classes> which will cause only the listed classes in persistence.xml to be used.