-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate generated mappings using assigned generator.
PostPosted: Thu Mar 05, 2009 5:40 pm 
Newbie

Joined: Thu Mar 05, 2009 5:00 pm
Posts: 1
I'm generating hbm.xml mapping files and POJO's using the ant tool in Hibernate 3.3.1.GA. Things are looking good except one thing; the mapping files are all coming out with the ID generator set to assigned. I'm using Postgresql 8.3 as the database and have an existing schema that has the id's linked to sequences. When I add records through PGAdmin the sequences are incremented and id's assigned. But when I try to do this through Hibernate it looks like it is explicitly adding the id field to the insert. The reverse engineering should set the generator to "sequence" and specify the sequence name, or perhaps just use "native". I've read the documentation for ant reverse engineering tools.

Question is simple: how do I get the hbm.xml mapping files to use native/sequence instead of assigned as the generator?

My ant file looks like this:

...
<target name="hibernate.fromdb">
<hibernatetool destdir="${gen}">
<jdbcconfiguration
configurationfile="hibernate.cfg.xml"
packagename="nz.co.ecngroup.rtl.common.dao"
revengfile="hibernate.reveng.xml"
/>
<hbm2hbmxml destdir="${gen}" />
<hbm2dao/>
<hbm2java jdk5="true"/>
</hibernatetool>
</target>
...

Configuration looks like this:

<?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.postgresql.Driver</property>
<property name="hibernate.connection.password">****</property>
<property name="hibernate.connection.url">jdbc:postgresql:rtl</property>
<property name="hibernate.connection.username">****</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
</session-factory>
</hibernate-configuration>


Reverse Engineering file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
<table-filter match-name=".*"/>
</hibernate-reverse-engineering>


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

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.