-->
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.  [ 9 posts ] 
Author Message
 Post subject: Custom Strategy for Java Class Names while reverse engg
PostPosted: Sun Feb 05, 2006 7:56 pm 
Newbie

Joined: Sun Jul 03, 2005 6:27 pm
Posts: 7
Hibernate version:3.1.2 and Hibernate Tools Version: 3.1.0.beta4

Hi, I'm trying to reverse engineer from existing db schema. I need to control the class names. For example table "LA_ADDRESS" should be mapped to "Address" class instead of default class "laAddress". I tried following class

public class ExampleStrategy extends DelegatingReverseEngineeringStrategy {

public ExampleStrategy(ReverseEngineeringStrategy delegate) {
super(delegate);
}

public String tableToClasName(TableIdentifier table)
{

if(table.getName().startsWith("LA_"))
{
return table.getName().substring(3);

}
else
return super.tableToClassName(table);
}

}

anything wrong with above class?

Please help me in this. Thanks in advance.

_________________
Bhim Bomma


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 1:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
looks alright to me - why ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 2:17 pm 
Newbie

Joined: Sun Jul 03, 2005 6:27 pm
Posts: 7
Max, I tried it in Eclipse using hibernate tools (3.1.0. beta4). I'm not sure whats the problem. Thanks.

_________________
Bhim Bomma


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 3:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so now it works ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 3:09 pm 
Newbie

Joined: Sun Jul 03, 2005 6:27 pm
Posts: 7
No. Its not working. I was just saying I tried it in Eclipse and it didn't work.

_________________
Bhim Bomma


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 3:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so what does not work mean ? and did you enter the correct strategy into the reveng strategy field ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 3:15 pm 
Newbie

Joined: Sun Jul 03, 2005 6:27 pm
Posts: 7
Yes, I enetered the correct class file name in reveng strategy field. It created "lpAddress" class, not the expected "Address" class to map the "LP_ADDRESS" table.

_________________
Bhim Bomma


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 3:19 pm 
Newbie

Joined: Sun Jul 03, 2005 6:27 pm
Posts: 7
I also tried columnToPropertyName() method as below and it worked. But the tableToClasName() didn't.

public String columnToPropertyName(TableIdentifier table, String column) {
if(column.equals("id")) {
return "myid";
} else {
return super.columnToPropertyName(table, column);
}
}

_________________
Bhim Bomma


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 06, 2006 4:10 pm 
Hibernate Team
Hibernate Team

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

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