0

In my application, I map a class, so that it starts with the application deployment. I'm trying to make the JPA search for a particular database table, a table referring to a properly mapped entity. If this table does not exist, I want the JPA create the table. If I use as an example, a java class called car, duly noted @Table (name = "car"), how do I get the JPA entityManager check and create this table if necessary in Java. Remembering that I am not referring to the in persistence.xml, I learn it in Java.

  • Automatic db schema creation is jpa implementation dependent, defined by a hint in the persistence.xml file. This is gonna change in JPA 2.1 see http://www.thoughts-on-java.org/standardized-schema-generation-data-loading-jpa-2-1/ – Leo May 28 '16 at 20:54
  • Have a look at this article : [SO#2585641](http://stackoverflow.com/questions/2585641/hibernate-jpa-db-schema-generation-best-practices) – DenisGL May 28 '16 at 20:56
  • No idea what @Leo means by "gonna change". JPA 2.1 was RELEASED in 2013, and has had schema generation capabilities since its release. Since you don't provide details of what you're doing (EMF configuration, the log, etc) not much of a response is possible. – Neil Stockton May 29 '16 at 05:36
  • @NeilStockton sorry, I am still in the JavaEE 6 days :-) – Leo May 29 '16 at 05:50
  • thanks guys, I was looking for the worst way to do what I want. I still want to implement this function in my project without using DDL persistence.xml, but try to import duties instead of escrevelas in java. again thanks for the help. – Nadinael Silva Teixeira Aug 28 '16 at 15:25

0 Answers0