-->
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: Filter column by name in hibernate.reveng.xml
PostPosted: Tue Jan 30, 2007 1:49 pm 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
Hi all,

I'm new in using hibernate in eclipse. I'm using Hibernate tools to generate Hibernate XML Mappings(hbm.xml). May I know how can I exclude all those fields name start with "_" in my table?
For e.g :
I have table Employee, with fields:
- empid,
- name,
- date_join.
...etc
I only want to generate the fields without "_". how can I do that ? Thanks for your response and suggestions.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 30, 2007 5:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the easiest i can think of is to write a custom reveng strategy that simply returns false for columns with a '_' in the method excludeColumn(...)

the other way is to use reveng.xml and explicit exclude all columns that you dont want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 6:12 am 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
Thanks max for the quick reply. I started to write a user strategy in myeclipse. This is my source.

package com.proj.product.commons.eo.revengtest;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;

public class MyTest1 extends DelegatingReverseEngineeringStrategy {
public MyTest1(ReverseEngineeringStrategy delegate) {
super(delegate);
}

public boolean excludeColumn(TableIdentifier identifier, String columnName) {

System.out.println("columnName Name = '"+ columnName + "'");

if (columnName.contains("_")) { return false; }
return super.excludeColumn(identifier, columnName);
}

I can compile it. After that, I try to set in the Hibernate Code generation,
In main tab,
package : com.proj.product.commons.eo.revengtest
reveng.strategy I put : com.proj.product.commons.eo.revengtest.MyTest1
when I click "Run" , I got an error :
Exception while generating code, "Count not create or find com.proj.product.commons.eo.revengtest.MyTest1 with one argument delegate constructor."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 6:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
are you using Hibernate Tools in a normal Eclipse or are you using the Hibernate Tools provided by MyEclipse ?

If running from within myeclipse their might be problems because of them bundeling a different and "mutated" version of the tools so it makes a difference in what to look after.

If you are running standalone this should definitly work assuming that class is in the classpath.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:27 am 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
I downloaded the Hibernate Tools from "http://download.jboss.org/jbosside/updates/development" and running in myeclipse. Is that consider "mutated" version ?

May I know how can I get rid of that error if I want to run my custom Hibernate Strategy class in myelipse ? Or what is your suggestion to run the custom strategy class ? Thanks advances for your response.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
The "mutation" i'm referring to is the version that MyEclipse contains. It is Hibernate Tools but they changed bits and pieces (and I don't know precisly which) thus there might be classloading issues when you use their version together with the real Hibernate Tools from hibernate.org.

I would appreciate if you could try and run it from a plain eclipse + hibernate tools (from us) and let me know if it is still a problem.

If it is still a problem then there is an Hibernate Tools issue; if it is not then its a compability issue created by MyEclipses' mutated version of hibernate tools.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 8:38 am 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
thanks again for your quick response. The problem solved.

I used myeclipse and hibernate-tools-3.2.0beta8. It is working with the previous source.

What I did was, add the classpath correctly in Hibernate console configuration. e.g : /<Source file>/build/classes.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 8:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ah ok, so it was "just" a classpath issue. Good.

btw. in b9 we will just use the classpath of the project so the problem would not have occured.

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