Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:from hibernate-tools-3.1.0.alpha5
Name and version of the database you are using:Informix Dynamic Server Version 9.30.UC2
Name and version of the database you are using:IBM Informix Dynamic Server Version 9.40.FC4W2X1
Hi everybody,
after long, tedious and unsuccessful research on this forum and google, i somehow succeeded in changing the default
Code:
generator class="assigned"
to
Code:
generator class="native"
which I needed for my legacy database schema.
I finally used a modified id.hbm.vm velocity template in cfg2hbm, in the following ugly way (sessionid is the PK column) :
Code:
....
#if(! $c2h.isIdentifierGeneratorProperties($property))
#set( $sessionproperty = "sessionid" )
#if ( $sessionproperty == "$property.name" )
<generator class="native" />
#else
<generator class="$property.Value.identifierGeneratorStrategy" />
#end
#else
<generator class="$property.Value.identifierGeneratorStrategy">
#set ($parameters = $c2h.getIdentifierGeneratorProperties($property))
....
Here is the except from the generated Session.hbm.xml :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="dao.Session" table="session">
<id name="sessionid" type="long">
<column name="sessionid" />
<generator class="native" />
</id>
<many-to-one name="actor" class="dao.Actor">
<column name="actorid" not-null="true" />
</many-to-one>
...
I'd love for somebody to tell me that there is another way to do what I did...