java - how to automatic create table in jpa persistence xml file? -


i using eclipse ide.i try following 2 .but failed..when manually create table in mysql database complete program run fine... want create table automatic respect entity class.

<property name="hibernate.hbm2ddl.auto" value="create"/>  <property name="hibernate.hbm2ddl.auto">update</property> 

here persistence file:

<?xml version="1.0" encoding="utf-8"?>   <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="jpatest2" transaction-type="resource_local">       <class>com.jpa.employee</class>      <properties>          <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hibernate"/>         <property name="javax.persistence.jdbc.user" value="umar"/>         <property name="javax.persistence.jdbc.password" value="umar"/>         <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver"/>         <property name="hibernate.show_sql" value="true"/>         <property name="hibernate.format_sql" value="true"/>       </properties> </persistence-unit> 

dont use hibernate specific options. jpa 2.1 provides

javax.persistence.schema-generation.database.action 

that can set "create", "drop", "drop-and-create", "none". way keep code jpa implementation independent


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -