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>
|
|