-->
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.  [ 2 posts ] 
Author Message
 Post subject: Reverse engineering ignore msrepl_tran_version columns
PostPosted: Wed Jan 21, 2009 9:25 am 
Newbie

Joined: Wed Jan 21, 2009 9:15 am
Posts: 1
Dear all,

I'm using the below Ant configuration to run the hibernate reverse engineering on a Microsoft SQL Server 2005 database.
I ran into a problem, which I think is due to replication on the database.

Replication adds a column named "msrepl_tran_version" to each table in the database. Sometimes, if Hibernate detects a table is only used to link two other tables, it does not create a mapping for it, which I like.
However, because of the addition of the "msrepl_tran_version" column, I suspect that Hibernate changed this decision, and now generated different mapping files ! Which means some of my code is broken as well.

I could of course change the code, but, can I also make Hibernate ignore this column (preferably for all tables)? I tried the following, which did not work:

Code:
<table name="TESTTABLE">
   <column name="msrepl_tran_version" exclude="true" />
</table>


The msrepl_tran_version was still there in the mapping file.

Thanks !
Jonne.


Code:
        <hibernatetool destdir="${src.java.dir}">
            <jdbcconfiguration
                propertyfile="${basedir}/myp.db.properties"
                revengfile="${basedir}/myp.reveng.xml"
               reversestrategy="nl.myp.hibernate.reveng.MypReverseEngineeringStrategy"/>
            <hbm2hbmxml/>
            <hbm2cfgxml/>
        </hibernatetool>


[hibernatetool] INFO: Hibernate Tools 3.2.1.GA
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2009 5:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Do this in your revengstrategy:

Code:
public boolean excludeColumn(TableIdentifier identifier, String columnName) {
  if(colmnName.equals("msrepl_tran_version")) {
     return false;
  } else {
    return super.excludeColumn(identifier, columnName);
   }
}


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