[jboss-user] [JBoss Tools (users)] - Re: Auto generate database on startup

dgolovin do-not-reply at jboss.com
Mon Jun 23 14:58:07 EDT 2008


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>

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4160020#4160020

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4160020



More information about the jboss-user mailing list