-->
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.  [ 10 posts ] 
Author Message
 Post subject: package in table-filter
PostPosted: Wed Mar 15, 2006 4:40 pm 
Newbie

Joined: Wed Mar 15, 2006 4:21 pm
Posts: 6
Hi,

I am trying to setup multiple package names for some sets of tables. I have given the package names in table-filter of reveng xml file, but that is not having any effect. All my java code gets generated in the package name specified under the jdbcconfiguration element of hibernate.cfg.xml.

<table-filter match-name="A_.*" package="com.model.a"/>
<table-filter match-name="B_.*" package="com.model.b"/>

I am using hibernate tools beta 4 version.
Thanks for the help.
Srini


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 3:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
could you please show one hbm.xml and the corresponding java file ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 4:05 am 
Newbie

Joined: Wed Mar 15, 2006 4:21 pm
Posts: 6
My hibernate reverse engineering xml -

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >



<hibernate-reverse-engineering>
<table-filter match-schema="DEV42" exclude="false" package="com.encover.mapping.util" match-name="EN_BB"/>

<table-filter match-schema="DEV42" exclude="false" package="com.encover.mapping.util" match-name="EN_OBJECT_STATE"/>

<table-filter match-schema="DEV42" exclude="false" package="com.encover.mapping.util" match-name="EN_NUMERATOR"/>

<table-filter match-schema="DEV42" exclude="false" package="com.encover.mapping.util.billing" match-name="EN_CC_LOG"/>

<table-filter match-schema="DEV42" exclude="false" package="com.encover.mapping.product" match-name="EN_PRODUCT_CONFIG"/>

<table-filter match-schema="DEV42" exclude="false" package="com.encover.mapping.product" match-name="EN_PRODUCT_ROLE"/>

</hibernate-reverse-engineering>



My hibernate cfg -
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC

      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory name="hibmode">
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.password">chess</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.146.133:1521:ENC9i</property>
        <property name="hibernate.connection.username">chess</property>
        <property name="hibernate.default_schema">CHESS</property>
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
    </session-factory>

</hibernate-configuration>


My build.xml (relevant portions)

Code:
<taskdef
     name="hibernatetool"
     classname="org.hibernate.tool.ant.HibernateToolTask"
     classpathref="hibtools.libraries"/>

<hibernatetool
  destdir="/home/syermal/Projects/hibernate1/src">

    <jdbcconfiguration
    configurationfile="hibernate4.cfg.xml"
    packagename="com.encover.model"    reversestrategy="org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy"
    revengfile="hibernate2.reveng.xml">
  </jdbcconfiguration>
  <hbm2hbmxml/>
  <hbm2java/>
</hibernatetool>


The code that is generated is in the package com.encover.model and not in any subprojects. Thanks for the help.

On a side note - What is the right tool and when should one choose hibernate tool over something like middlegen/xdoclet? I was just wondering about what you have to say. We are in the mode of moving to hibernate. I was hoping there might be some best practices that could be followed.

Thanks,
Srini.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 4:13 am 
Newbie

Joined: Wed Mar 15, 2006 4:21 pm
Posts: 6
java code -
Code:
package com.encover.model;

// Generated Mar 16, 2006 12:12:44 AM by Hibernate Tools 3.1.0.beta4



import java.math.BigDecimal;

import java.util.Date;





/**

* EnBb generated by hbm2java

*/



public class EnBb  implements java.io.Serializable {





    // Fields   



     private BigDecimal oid;

     private BigDecimal version;

     private String messageId;

     private String messageIdLk;

     private String messageDesc;

     private BigDecimal portalType;

     private String createdBy;

     private Date createdTime;

     private String modifiedBy;

     private Date modifiedTime;

     private BigDecimal seqNum;





    // Constructors



    /** default constructor */

    public EnBb() {

    }



   /** minimal constructor */

    public EnBb(BigDecimal oid) {

        this.oid = oid;

    }

   

    /** full constructor */

    public EnBb(BigDecimal oid, String messageId, String messageIdLk, String messageDesc, BigDecimal portalType, String createdBy, Date createdTime, String modifiedBy, Date modifiedTime, BigDecimal seqNum) {

        this.oid = oid;

        this.messageId = messageId;

        this.messageIdLk = messageIdLk;

        this.messageDesc = messageDesc;

        this.portalType = portalType;

        this.createdBy = createdBy;

        this.createdTime = createdTime;

        this.modifiedBy = modifiedBy;

        this.modifiedTime = modifiedTime;

        this.seqNum = seqNum;

    }

   



   

    // Property accessors



    public BigDecimal getOid() {

        return this.oid;

    }

   

    public void setOid(BigDecimal oid) {

        this.oid = oid;

    }



    public BigDecimal getVersion() {

        return this.version;

    }

   

    public void setVersion(BigDecimal version) {

        this.version = version;

    }



    public String getMessageId() {

        return this.messageId;

    }

   

    public void setMessageId(String messageId) {

        this.messageId = messageId;

    }



    public String getMessageIdLk() {

        return this.messageIdLk;

    }

   

    public void setMessageIdLk(String messageIdLk) {

        this.messageIdLk = messageIdLk;

    }



    public String getMessageDesc() {

        return this.messageDesc;

    }

   

    public void setMessageDesc(String messageDesc) {

        this.messageDesc = messageDesc;

    }



    public BigDecimal getPortalType() {

        return this.portalType;

    }

   

    public void setPortalType(BigDecimal portalType) {

        this.portalType = portalType;

    }



    public String getCreatedBy() {

        return this.createdBy;

    }

   

    public void setCreatedBy(String createdBy) {

        this.createdBy = createdBy;

    }



    public Date getCreatedTime() {

        return this.createdTime;

    }

   

    public void setCreatedTime(Date createdTime) {

        this.createdTime = createdTime;

    }



    public String getModifiedBy() {

        return this.modifiedBy;

    }

   

    public void setModifiedBy(String modifiedBy) {

        this.modifiedBy = modifiedBy;

    }



    public Date getModifiedTime() {

        return this.modifiedTime;

    }

   

    public void setModifiedTime(Date modifiedTime) {

        this.modifiedTime = modifiedTime;

    }



    public BigDecimal getSeqNum() {

        return this.seqNum;

    }

   

    public void setSeqNum(BigDecimal seqNum) {

        this.seqNum = seqNum;

    }

   

















}



hbm file -
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 Mar 16, 2006 12:12:11 AM by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
    <class name="com.encover.model.EnBb" table="EN_BB">
        <id name="oid" type="big_decimal">
            <column name="OID" scale="0" />
            <generator class="assigned" />
        </id>
        <version name="version" type="big_decimal">
            <column name="VERSION" precision="22" scale="0" not-null="true" />
        </version>
        <property name="messageId" type="string">
            <column name="MESSAGE_ID" length="40" />
        </property>
        <property name="messageIdLk" type="string">
            <column name="MESSAGE_ID_LK" length="40" />
        </property>
        <property name="messageDesc" type="string">
            <column name="MESSAGE_DESC" length="4000" />
        </property>
        <property name="portalType" type="big_decimal">
            <column name="PORTAL_TYPE" scale="0" />
        </property>
        <property name="createdBy" type="string">
            <column name="CREATED_BY" length="40" />
        </property>
        <property name="createdTime" type="date">
            <column name="CREATED_TIME" length="7" />
        </property>
        <property name="modifiedBy" type="string">
            <column name="MODIFIED_BY" length="40" />
        </property>
        <property name="modifiedTime" type="date">
            <column name="MODIFIED_TIME" length="7" />
        </property>
        <property name="seqNum" type="big_decimal">
            <column name="SEQ_NUM" precision="22" scale="0" />
        </property>
    </class>
</hibernate-mapping>


I tried not specifying the strategy in the jdbcconfiguration as well, the same result occurs.

Srini.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 4:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the reveng uses schema DEV42 where as you have default schema set to CHESS - why is that ?

currently we use default schema as the "starting" point for reverse engineering and in this case it means that only the CHESS schema is actually being read.

Regarding using xdoclet/middlegen vs hibernate toools then i can only say choose what fits your development environment - but remember that using xdoclet/middlegen does not exclude you from still benefitting from hibernate tools since it still can be used to do its stuff based just on the mapping files.

but if you are on jdk 5 and hibernate 3.1 then i would suggest looking into annotations.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 5:55 am 
Newbie

Joined: Wed Mar 15, 2006 4:21 pm
Posts: 6
Thanks much. I am still a lil confused.

I am using couple of different config files connecting to different databases, and posted the wrong config file. The schema I used is DEV42 and the table-filter point to right schema.

The schema is not the issue here. Is the package attribute in table-filter considered for package names of generated java classes at all? If not how can I get multiple tables in the same schema to belong to different packages? What I am trying to do here, is to group multiple tables of a biz entity into a logical java package.

Please let me know if I am not clear. I will try and explain in more detail.
Thanks,
Srini.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 6:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if your default schema in cfg.xml does not match the reveng.xml then that is relevant since you would never actually read the schema you are trying to match against.

Anyhow you say that you are using a cfg.xml with a proper (or not set) default schema then it should work.

put a bug report in jira with the details.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 6:21 am 
Newbie

Joined: Wed Mar 15, 2006 4:21 pm
Posts: 6
Thanks. Will do
Srini


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 11:52 pm 
Newbie

Joined: Wed Mar 15, 2006 4:21 pm
Posts: 6
Observation -

Debugging the code I found the TableIdentifier seems to have the schema always to null for my configuration. So I removed the match-schema attribute from the reverse engg file and it worked fine.

Srini.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 1:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
schema will be null when schema==default schema this allows the codegeneration to generate much more portable/movable mappings.

_________________
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.  [ 10 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.