-->
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.  [ 6 posts ] 
Author Message
 Post subject: Trying to understand reverse engineering process...
PostPosted: Fri Dec 16, 2005 6:57 am 
Newbie

Joined: Thu Dec 15, 2005 7:46 am
Posts: 12
Hello,

I'm trying to better understand internals of the reverse engineering strategies. So I've made a class (extending DelegatingReverseEngineeringStrategy) that override the DefaultReverseEngineeringStrategy.
In this class I've defined a method foreignKeyToEntityName that is the one-to-one copy of the same method contained in the class DefaultReverseEngineeringStrategy.

public String foreignKeyToEntityName(String keyname, TableIdentifier fromTable, List fromColumnNames, TableIdentifier referencedTable, List referencedColumnNamesString, boolean uniqueReference) {
String propertyName = Introspector.decapitalize(StringHelper.unqualify(tableToClassName(referencedTable)));

if(!uniqueReference)
if(fromColumnNames != null && fromColumnNames.size() == 1)
{
String columnName = ((Column)fromColumnNames.get(0)).getName();
propertyName = propertyName + "By" + toUpperCamelCase(columnName);
} else
{
propertyName = propertyName + "By" + toUpperCamelCase(keyname);
}
return propertyName;
}

I was surprised to see that results that I've obtained are not the same....

For example, I've a table called "CONTATTI" containing two one-to-many relationships having the same target table.
If I don't specify a class for the reversestrategy attribute I obtain this result:

<many-to-one name="tipocontatto" class="it.csi.ccrp_bo.hibernate_stat.Tipocontatto" fetch="select">
<column name="IDTIPOCONTATTO" precision="22" scale="0" not-null="true" />
</many-to-one>
<many-to-one name="tipocontatto_1" class="it.csi.ccrp_bo.hibernate_stat.Tipocontatto" fetch="select">
<column name="IDTIPOCONTATTO_OUT" precision="22" scale="0" />
</many-to-one>

These results are the same that I obtain with Hibernatetools called directly from Eclipse.

Using my own reversestrategy class I obtained:

<many-to-one name="tipocontattoByIdtipocontatto" class="it.csi.ccrp_bo.hibernate_stat.Tipocontatto" fetch="select">
<column name="IDTIPOCONTATTO" precision="22" scale="0" not-null="true" />
</many-to-one>
<many-to-one name="tipocontattoByIdtipocontattoOut" class="it.csi.ccrp_bo.hibernate_stat.Tipocontatto" fetch="select">
<column name="IDTIPOCONTATTO_OUT" precision="22" scale="0" />
</many-to-one>

Now the questions are:
Why in one case I obtained 'tipocontatto' and 'tipocontatto_1' and in the other I obtained those different (and I think more correct) results ?
What is the class used If I don't specify a reversestrategy one ? I thought that is was DefaultReverseEngineeringStrategy but obviously I were in mistake.

Thanks in advance for you support.
Janniz


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 17, 2005 12:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
users have reported this before but noone have never given me a testcase that reproduces this on hibernate tools beta's.

So please do by putting it in jira.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 18, 2005 10:17 pm 
Beginner
Beginner

Joined: Wed Nov 02, 2005 3:29 pm
Posts: 20
max wrote:
users have reported this before but noone have never given me a testcase that reproduces this on hibernate tools beta's.

So please do by putting it in jira.


That sounds very similar to my issue HBX-467 (which include everything
neeed to reproduce the problem).

George


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 3:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
No - your issue is about how the naming strategy actually works, and that case actually shows that the codegenerator does not append _1,_2 ...

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 5:25 am 
Newbie

Joined: Thu Dec 15, 2005 7:46 am
Posts: 12
Ok, I'll post it on Jira on my lunch time this afternoon.
What do you need to make a testcase ? (Hibernate hbm.xml ? ER diagram of the db or what else ?)

Thank you
Janniz


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 5:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i need a build.xml and the source of your custom strategy so i can reproduce the case.

In short the actual settings/files needed to reproduce it.

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