Hello,
I'm getting strange behavior. I'm doing reverse code generation using hibernate tools.
Normally it works perfectly but sometimes it does not applies right the config, for example:
I have this in my reveng.xml file:
NIOTE: Color tag not recognized in the forum inside CODE tag.
Code:
<table name="contact_type" schema="public">
<primary-key>
<generator class="sequence">
<param name=[color=#FFFF00]"sequence"[/color]>contact_type_id_contact_type_seq</param>
</generator>
<key-column name="id_contact_type" />
</primary-key>
</table>
The sequence is not generated correctly:
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">
<!-- Generated 15-feb-2012 0:59:59 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.level2.enterprise.hibernate.generated.ContactType" table="contact_type">
<id name="idContactType" type="java.lang.Integer">
<column name="id_contact_type" />
<generator class="[color=#FFFF00]assigned[/color]" />
</id>
<many-to-one name="contactTypeCategory" class="com.level2.enterprise.hibernate.generated.ContactTypeCategory" fetch="select">
<column name="id_contact_type_category" not-null="true" />
</many-to-one>
<property name="contactTypeDescription" type="string">
<column name="contact_type_description" length="50" not-null="true" />
</property>
<set name="contactRecords" table="contact_record" inverse="true" lazy="true" fetch="select">
<key>
<column name="id_contact_type" not-null="true" />
</key>
<one-to-many class="com.level2.enterprise.hibernate.generated.ContactRecord" />
</set>
</class>
</hibernate-mapping>
The strange thing here is that sometimes it gets generated correctly. The exact use case is still not determined but I can say that doing things in eclipse like opening the class, closing the file, etc. Affects the result.
I also have seen sometimes and in documentation that param is configured differently:
<param name="
table">contact_type_id_contact_type_seq</param>
I tried both configuration but it seems to do same thing.
I've also checked my database permissions. And set even a GRANT ALL ... TO PUBLIC; to everything. But makes not difference.
My problem is that I get not consistent code. And some code is failing because no sequence defined so I have to put nextval manually.
Can someone point me to the right direction?
Why the sequence is not recognized?
Is this configuration right?
How can I force the sequence being generated right?
Thank you in advance.