java - How to create Objects in database if does not exists with JPA? -
i have web application use jpa / hibernate want know how hibernate can generate non-existent tables entities. persistence file follows:
what can add property ?
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="bankingapp"> <provider> org.hibernate.ejb.hibernatepersistence</provider> <properties> <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.oracledriver"/> <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:xe"/> <property name="hibernate.connection.username" value="user"/> <property name="hibernate.connection.password" value="password"/> <property name="hibernate.dialect" value="org.hibernate.dialect.oracle10gdialect"/> </properties> </persistence-unit> </persistence>
you can add property
<property name="hibernate.hbm2ddl.auto" value="update"/>
the possible values property are:
- validate: validates schema
- update: update schema
- create: create schema, override previous data
- create-drop: create schema , drop schema @ end of session
Comments
Post a Comment