How to create Objects in database if does not exists with JPA?
10,773
You can add this property
<property name="hibernate.hbm2ddl.auto" value="update"/>
The possible values for this property are:
- validate: Only validates the schema
- update: Update the schema
- create: Create the schema, override previous data
- create-drop: Create the schema and drop the schema at the end of the session
Author by
Admin
Updated on July 26, 2022Comments
-
Admin almost 2 years
I have a web application that I use JPA / Hibernate I want to know how to hibernate can generate the non-existent tables from entities. the persistence file is as follows:
What I can add as 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>