-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Need help with Hibernate Tools: Hbm generation
PostPosted: Fri Jan 05, 2007 9:04 am 
Newbie

Joined: Fri Jan 05, 2007 5:23 am
Posts: 2
Location: Mumbai
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 12:15 am 
Newbie

Joined: Wed Feb 21, 2007 3:09 am
Posts: 16
HI..
You forgto to add reveng.xml file
Anyway, you need to add following line in your reveng.xml file
<table name="person" schema="public">
<primary-key>
<!-- setting up a specific id generator for a table -->
<generator class="sequence">
<param name="person_seq">person_seq</param>
</generator>
</primary-key>
</table>



where person_seq is a sequence in datable. You needs to be created proir to use this script.
or



<table name="book" schema="public">
<primary-key>
<!-- setting up a specific id generator for a table -->
<generator class="sequence" />
</primary-key>
</table>

Regds,
Ramesh K.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.