-->
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.  [ 7 posts ] 
Author Message
 Post subject: Reverse Engineer identity column from DB2
PostPosted: Sun Oct 14, 2007 7:34 pm 
Beginner
Beginner

Joined: Sun Oct 14, 2007 7:29 pm
Posts: 23
I am trying to configure a reverse engineering xml file such that the Hibernate Tools will properly reverse engineer my DB2 Identity columns to the "identity" generator class rather than "assigned". I tired adding the following lines to my hibernate.reveng.xml file:

<table-filter match-schema="MYSCHEMA" match-name=".*"></table-filter>
<table name="COMPDATA" class="Companydata">
<primary-key>
<generator class="identity">
</generator>
<key-column name="COMPANYID"/>
</primary-key>
</table>

However, it continues to reverse engineer the Compdata class with an "assigned" generator class rather than "identity".

Has any one else ran into this problem and/or found a way to get this to work?

Thanks,

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 1:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
it is probably not matching on the right name.

show the generate hbm.xml or class file for that class (just the header and a few properties would be enough.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: RE: Reverse Engineer identity column from DB2
PostPosted: Mon Oct 15, 2007 3:37 am 
Beginner
Beginner

Joined: Sun Oct 14, 2007 7:29 pm
Posts: 23
I believe you are right -- it is not picking up on the table name because if it did, the resulting class would have been named "CompanyData" and not "Compdata", which is the name of the table. In my reverse engineer file, do I need to include the schema name in the <table name> parameter value of my reverse engineer <table-filter>


Reverse engineer file:
Code:
table-filter match-schema="FAWEB" match-name=".*"></table-filter>
   <table name="COMPDATA" class="Companydata">
     <primary-key>
       <generator class="identity">
       </generator>
       <key-column name="COMPANYID"/>
      </primary-key>
     </table>



Here is the resulting mapping file, Compdata.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">
<!-- Generated Oct 14, 2007 6:09:13 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
    <class name="com.faweb.entities.Compdata" table="COMPDATA" schema="FAWEB" dynamic-insert="true">
    <!-- dynamic-insert (optional, defaults to false): Specifies that INSERT SQL should be generated at runtime
and contain only the columns whose values are not null. -->
        <id name="companyid" type="int">
            <column name="COMPANYID" />
            <generator class="assigned" />
        </id>
        <many-to-one name="contactinfo" class="com.faweb.entities.Contactinfo" fetch="select">
            <column name="CONTACTID" />
        </many-to-one>
        <property name="companyname" type="string">
            <column name="COMPANYNAME" length="50" not-null="true" />
        </property>
        <property name="remBal" type="big_decimal">
            <column name="REM_BAL" precision="11" />
        </property>
        <property name="accesscode" type="string">
            <column name="ACCESSCODE" length="50" />
        </property>
        <set name="compmsgses" inverse="true">
            <key>
                <column name="COMPANYID" not-null="true" />
            </key>
            <one-to-many class="com.faweb.entities.Compmsgs" />
        </set>
        <set name="compdeps" inverse="true">
            <key>
                <column name="COMPANYID" not-null="true" />
            </key>
            <one-to-many class="com.faweb.entities.Compdep" />
        </set>
        <set name="usrprofileses" inverse="true" table="USRPROFILES_X_COMPDATA">
            <key>
                <column name="COMPANYID" not-null="true" />
            </key>
            <many-to-many entity-name="com.faweb.entities.Usrprofiles">
                <column name="UID" not-null="true" />
            </many-to-many>
        </set>
        <set name="fratesconfigs" inverse="true">
            <key>
                <column name="COMPANYID" />
            </key>
            <one-to-many class="com.faweb.entities.Fratesconfig" />
        </set>
        <set name="actlogs" inverse="true">
            <key>
                <column name="COMPANYID" />
            </key>
            <one-to-many class="com.faweb.entities.Actlog" />
        </set>
    </class>
</hibernate-mapping>



and here is the resulting class file, Compdata.java:

Code:
/ Generated Oct 14, 2007 6:09:13 PM by Hibernate Tools 3.2.0.b9

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

/**
* Compdata generated by hbm2java
*/
public class Compdata implements java.io.Serializable {

   private int companyid;

   private Contactinfo contactinfo;

   private String companyname;

   private BigDecimal remBal;

   private String accesscode;

   private Set compmsgses = new HashSet(0);

   private Set compdeps = new HashSet(0);

   private Set usrprofileses = new HashSet(0);

   private Set fratesconfigs = new HashSet(0);

   private Set actlogs = new HashSet(0);

   public Compdata() {
   }

   public Compdata(int companyid, String companyname) {
      this.companyid = companyid;
      this.companyname = companyname;
   }

   public Compdata(int companyid, Contactinfo contactinfo, String companyname,
         BigDecimal remBal, String accesscode, Set compmsgses, Set compdeps,
         Set usrprofileses, Set fratesconfigs, Set actlogs) {
      this.companyid = companyid;
      this.contactinfo = contactinfo;
      this.companyname = companyname;
      this.remBal = remBal;
      this.accesscode = accesscode;
      this.compmsgses = compmsgses;
      this.compdeps = compdeps;
      this.usrprofileses = usrprofileses;
      this.fratesconfigs = fratesconfigs;
      this.actlogs = actlogs;
   }

   public int getCompanyid() {
      return this.companyid;
   }

   public void setCompanyid(int companyid) {
      this.companyid = companyid;
   }

   public Contactinfo getContactinfo() {
      return this.contactinfo;
   }

   public void setContactinfo(Contactinfo contactinfo) {
      this.contactinfo = contactinfo;
   }

   public String getCompanyname() {
      return this.companyname;
   }

   public void setCompanyname(String companyname) {
      this.companyname = companyname;
   }

   public BigDecimal getRemBal() {
      return this.remBal;
   }

   public void setRemBal(BigDecimal remBal) {
      this.remBal = remBal;
   }

   public String getAccesscode() {
      return this.accesscode;
   }

   public void setAccesscode(String accesscode) {
      this.accesscode = accesscode;
   }

   public Set getCompmsgses() {
      return this.compmsgses;
   }

   public void setCompmsgses(Set compmsgses) {
      this.compmsgses = compmsgses;
   }

   public Set getCompdeps() {
      return this.compdeps;
   }

   public void setCompdeps(Set compdeps) {
      this.compdeps = compdeps;
   }

   public Set getUsrprofileses() {
      return this.usrprofileses;
   }

   public void setUsrprofileses(Set usrprofileses) {
      this.usrprofileses = usrprofileses;
   }

   public Set getFratesconfigs() {
      return this.fratesconfigs;
   }

   public void setFratesconfigs(Set fratesconfigs) {
      this.fratesconfigs = fratesconfigs;
   }

   public Set getActlogs() {
      return this.actlogs;
   }

   public void setActlogs(Set actlogs) {
      this.actlogs = actlogs;
   }

}


Top
 Profile  
 
 Post subject: Re: RE: Reverse Engineer identity column from DB2
PostPosted: Mon Oct 15, 2007 6:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
mcburton3 wrote:
I believe you are right -- it is not picking up on the table name because if it did, the resulting class would have been named "CompanyData" and not "Compdata", which is the name of the table. In my reverse engineer file, do I need to include the schema name in the <table name> parameter value of my reverse engineer <table-filter>



Yes - if that schema is not your default schema (set via hibernate.default_schema) then you need to specify it.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Reverse Engineer identity column from DB2
PostPosted: Mon Oct 15, 2007 4:48 pm 
Beginner
Beginner

Joined: Sun Oct 14, 2007 7:29 pm
Posts: 23
Quote:
Yes - if that schema is not your default schema (set via hibernate.default_schema) then you need to specify it.


Thanks Max, but I checked and I do have my default schema set appropriately in my hibernate.cfg.xml file:
Code:
       <property name="hibernate.default_schema">faweb</property>


Does anything else stand out?

Thanks,

-Matt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 16, 2007 1:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes FAWEB != faweb ;)

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: RE: Reverse Engineer Identity Column from DB2
PostPosted: Tue Oct 16, 2007 8:49 am 
Beginner
Beginner

Joined: Sun Oct 14, 2007 7:29 pm
Posts: 23
Quote:
yes FAWEB != faweb ;)


I didn't realize the parser was case sensitive. Thank you Max!

-Matt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.