-->
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.  [ 8 posts ] 
Author Message
 Post subject: Hibernate Reverse Engineering tool ignores reveng.xml file
PostPosted: Mon Apr 24, 2006 7:51 pm 
Newbie

Joined: Mon Apr 24, 2006 7:22 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate Tools 3.1.0.beta5

Name and version of the database you are using:Oracle 9i

Eclipse WTP 1.5 Nightly Build
Eclipse 3.2RC1


I am having a problem where the tool reads the reveng.xml file, obeys the table filters and even complains when there is a schema mistake, but completely ignores the overrides when generating the hbm and java files.

for e.g. in the table override below, i am putting overrides for primary-key etc.
but in the hbm file, the primary key is generated as "long" and with a generator as "assigned"

<table name="OPTOUTSOURCELOOKUP" schema="OSTN" class="com.mypackage.OptOutSourceLookup">
<primary-key>
<generator class="sequence">
<param name="sequence">SEQ_OPTOUTSOURCELOOKUPID</param>
</generator>
<key-column name="OPTOUTSOURCEID" jdbc-type="NUMERIC" property="id" type="java.lang.Long"/>
</primary-key>
</table>

This same file is working for another colleague with 3.1.0 beta4a.. I tried using beta4a .. but gettting the same problem, thought beta5 would help.. but no dice..

I thought it might be an eclipse problem.. so i replaced my eclipse.. even the hibernate tools specific settings from the workspace.. but it doesnt matter..

I am just wondering if anyone else is seeing this..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 2:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what is in your hibernate.cfg.xml ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 2:50 pm 
Newbie

Joined: Mon Apr 24, 2006 7:22 pm
Posts: 4
I figured it out after some playing.. the schema attribute was causing a problem:

Quote:
<table name="OPTOUTSOURCELOOKUP" schema="OSTN" class="com.mypackage.OptOutSourceLookup">


After I removed it, it was working as expected. I hit another bug though. The tool now ignores overrides relating to the foreign keys. If i say exclude="true" for a field that has a foreign key, it ignores it, even if I have a foreign key declaration for the same field later in the file. In addition, it creates another field in the class for the foreign key declaration for the same field, however ignoring overrides for property names etc.

My hibernate.cfg.xml:


Code:
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.password">xxxx</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@myhost:1521:POST</property>
        <property name="hibernate.connection.username">xxxx</property>
        <property name="hibernate.default_schema">OSTN</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
    </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 5:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, schema is not needed since you have a default schema.

Your other question you need to examplify for me ... e.g. what is in the reveng.xml etc.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 5:21 pm 
Newbie

Joined: Mon Apr 24, 2006 7:22 pm
Posts: 4
Code:
   <table name="CONSUMER">
      <primary-key>
         <generator class="sequence">
            <param name="sequence">SEQ_CONSUMERID</param>
         </generator>
         <key-column name="ID" jdbc-type="NUMERIC" property="id" type="java.lang.Long"/>
      </primary-key>
      <column name="CONSOLIDATEDTOCONSUMERID" jdbc-type="NUMERIC" property="consolidatedToConsumer" type="Consumer"/>
      <column name="CANCOMMUNICATE" jdbc-type="NUMERIC" property="canCommunicate" type="java.lang.Boolean"/>
      <column name="COMMUNICATEOPTOUTDATE" jdbc-type="DATE" property="communicateOptOutDate" type="java.lang.Date"/>
   

      <column name="CANMAIL" jdbc-type="NUMERIC" property="canMail" type="java.lang.Boolean"/>
      <column name="MAILOPTOUTDATE" jdbc-type="DATE" property="mailOptOutDate" type="java.lang.Date"/>
      <column name="MAILOPTOUTSOURCEID" jdbc-type="NUMERIC" property="mailOptOutSource" type="OptOutSourceLookup" exclude="true"/>

      <column name="CANCALL" jdbc-type="NUMERIC" property="canCall" type="java.lang.Boolean"/>
      <column name="CALLOPTOUTDATE" jdbc-type="DATE" property="callOptOutDate" type="java.lang.Date"/>
      <column name="CALLOPTOUTSOURCEID" jdbc-type="NUMERIC" property="callOptOutSource" type="OptOutSourceLookup"/>

      <column name="CANEMAIL" jdbc-type="NUMERIC" property="canEmail" type="java.lang.Boolean"/>
      <column name="EMAILOPTOUTDATE" jdbc-type="DATE" property="emailOptOutDate" type="java.lang.Date"/>
      <column name="EMAILOPTOUTSOURCEID" jdbc-type="NUMERIC" property="emailOptOutSource" type="OptOutSourceLookup"/>

      <foreign-key foreign-table="OPTOUTSOURCELOOKUP">
         <column-ref local-column="MAILOPTOUTSOURCEID" foreign-column="OPTOUTSOURCEID"/>
         <many-to-one property="mailOptOutSource"/>
      </foreign-key>
   </table>

   <table name="OPTOUTSOURCELOOKUP" class="com.mypackage.OptOutSourceLookup">
      <primary-key>
         <generator class="sequence">
            <param name="sequence">SEQ_OPTOUTSOURCELOOKUPID</param>
         </generator>
         <key-column name="OPTOUTSOURCEID" jdbc-type="NUMERIC" property="id" type="java.lang.Long"/>
      </primary-key>
   </table>


This generates something like this:
Code:
 

    private OptOutSourceLookup optoutsourcelookupByMailoptoutsourceid;

    private OptOutSourceLookup optoutsourcelookupByMailoptoutsourceid_1;


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 3:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as per the docs (they have been updated for this release you know ;)

use constraint-name to identify existing foreing-keys to avoid defining a new one.

Code:
<foreign-key constrain-name="BLA_BLA">
         <many-to-one property="mailOptOutSource"/>
</foreign-key>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:08 pm 
Newbie

Joined: Mon Apr 24, 2006 7:22 pm
Posts: 4
max wrote:
as per the docs (they have been updated for this release you know ;)

use constraint-name to identify existing foreing-keys to avoid defining a new one.

Code:
<foreign-key constrain-name="BLA_BLA">
         <many-to-one property="mailOptOutSource"/>
</foreign-key>



I noticed that if I use constraint-name="actual-name-in-Oracle" I get Error Foreign key actual-name-in-Oracle already defined in the database.

If I specify a fictitious name, I get the many-to-one property defined correctly but the set defined twice. If I put the set definition in and set exclude = true, then it only shows up once but its the default generated one, I can't rename it using the reveng.xml file.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
please submit a bug report if you are 1000% sure your foreign-key definition just uses constraint-name.

_________________
Max
Don't forget to rate


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

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.