I am trying to generate hbm with hibernate tools for mysql 5.0 database.
The generator class is generated as assigned for auto_increment. This should be of type native.
Hibernate Tools version:Hibernate Tools 3.2.0.beta8
Hibernate version: Hibernate3
Ant script to generate hbm
<hibernatetool>
<jdbcconfiguration packagename="${hibernate.domain.package.name}" propertyfile="${build.dir}\build.properties" revengfile="${build.dir}\revenge.xml" />
<hbm2hbmxml destdir="${build.temp.dir}" templatepath="${hbm.template.path}" >
<property key="jdk5" value="true"/>
<property key="ejb3" value="false"/>
</hbm2hbmxml>
</hibernatetool>
Mapping documents: hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">messa</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/messa</property>
<property name="hibernate.connection.username">messa</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
</session-factory>
</hibernate-configuration>
Hbm generated is:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jan 5, 2007 6:08:25 PM by Hibernate Tools 3.2.0.beta8 -->
<hibernate-mapping>
<class
name="com.tools.domain.Application"
table="application"
catalog="messagio"
>
<comment></comment>
<id
name="id"
type="java.lang.Integer"
>
<meta attribute="use-in-equals" inherit="false" >true</meta>
<meta attribute="use-in-tostring" inherit="false" >true</meta>
<column name="id" />
<generator class="assigned" />
</id>
<many-to-one
name="Option"
class="com.tools.domain.Option"
fetch="select"
>
<column name="option_id" >
<comment></comment>
</column> </many-to-one>
<property
name="dbCreationDate"
type="timestamp"
>
<column name="db_creation_date" length="19" >
<comment></comment>
</column> </property>
<property
name="dbModificationDate"
type="timestamp"
>
<column name="db_modification_date" length="19" >
<comment></comment>
</column> </property>
</class>
</hibernate-mapping>
Name and version of the database you are using:Mysql 5.0
table structure is
CREATE TABLE `application` (
`id` int(11) NOT NULL auto_increment,
`option_id` int(11) default NULL,
`db_creation_date` datetime default NULL,
`db_modification_date` datetime default NULL,
PRIMARY KEY (`id`),
KEY `fk_application_option` (`option_id`),
CONSTRAINT `fk_application_option` FOREIGN KEY (`application_option_id`) REFERENCES `option` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
_________________ Thanks & Regards,
Alam Ansari
|