11/30/07

export db in hibernate3 ant

I try the example in "Hibernate Quickly" ebook and found that using SchemaExportTask to export database in build.xml file is not work in hibernate3. In hibernate3, export database done by use annotations like this

<target name="schema-export" >
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="schema.classpath" />
<hibernatetool destdir="${sql.dir}">
<annotationconfiguration configurationfile="${src.java.dir}/hibernate.cfg.xml" />
<hbm2ddldir}/hibernate.cfg.xml"
drop="true"
create="true"
export="true"
outputfilename="helloworld-ddl.sql"
delimiter=";"
format="true"/>
</hibernatetool>
</target>

thanks, Jon Rose for howto.

note1: transaction support in mysql need "TYPE=InnoDB" when create the table.
note2: InnoDB support begin with mysql4.0. In old version like 3.23 need to add this code in my.cnf [/etc/mysql/my.cnf or /etc/my.cnf in FC3].

[mysqld]
innodb_data_file_path=ibdata1:500M


Now to add "type=InnoDB" in generated script, Dialect property in hibernate.cfg.xml must be
<property name="dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</property>

1 comments:

123 123 said...

Nice story you got here. It would be great to read a bit more concerning this topic.
By the way look at the design I've made myself High class escorts