This content has been marked as final.
Show 2 replies
-
1. Re: Auto generate database on startup
cash1981 Jun 23, 2008 8:18 AM (in response to cash1981)I think I found it by using persistence.xml.
Thanks anyways -
2. Re: Auto generate database on startup
dgolovin Jun 23, 2008 2:58 PM (in response to cash1981)This can be done by adding hibernate.hbm2ddl.auto property for persistence-unit in persistence.xml file.
It enable utomatic validation or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly.
Available values are: validate | update | create | create-drop
Exampe:<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="sample"> <jta-data-source>java:/DefaultDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </properties> </persistence-unit> </persistence>