Configuring hibernate.reveng.xml to detect a sequence PK generator with hibernate3-maven-plugin and

Posted by mmm on Stack Overflow See other posts from Stack Overflow or by mmm
Published on 2010-06-06T17:20:40Z Indexed on 2010/06/06 21:22 UTC
Read the original article Hit count: 581

Filed under:
|
|
|

Hi,

is there a way to configure hibernate3-maven-plugin so that a sequence generator is detected for a primary-key? I'm using a bottom-up approach for hibernate configuration (which means letting hibernate-tools generate the hibernate configuration using a jdbc-connection for you via reverse-engineering on an existing database schema). I've read this, but also this already (those two can be unrelated, but can also leave a hint). My hibernate.reveng.xml is the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering 
 SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
    <table name="ORDERS">
        <primary-key>
            <!-- setting up a specific id generator for a table -->
            <generator class="sequence">
                <param name="sequence">ORDERS_ORDER_ID_seq</param>
            </generator>
            <key-column name="ORDER_ID"/>
        </primary-key>
    </table>
</hibernate-reverse-engineering>

And I'm expecting it to generate an Orders.hbm.xml file like this:

<?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 2010-06-06 18:55:42 by Hibernate Tools 3.2.2.GA -->
<hibernate-mapping>
    <class name="some.package.Orders" table="orders" schema="public">
        <id name="orderId" type="long">
            <column name="order_id" />
            <generator class="sequence">
                <param name="sequence">ORDERS_ORDER_ID_seq</param>
            </generator>
        </id>
    ...
    </class>
</hibernate-mapping>

...but receiving this instead:

<?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 2010-06-06 18:55:42 by Hibernate Tools 3.2.2.GA -->
<hibernate-mapping>
    <class name="some.package.Orders" table="orders" schema="public">
        <id name="orderId" type="long">
            <column name="order_id" />
            <generator class="assigned" />
        </id>
    ...
    </class>
</hibernate-mapping>

I know my hibernate.reveng.xml is being read by hibernate3-maven-plugin, as I experience maven errors whenever syntax errors appear in the file, so pom.xml seems to be correct and hibernate.reveng.xml syntactically correct.

Any clues?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about maven-2