-->
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.  [ 7 posts ] 
Author Message
 Post subject: many-to-many problem
PostPosted: Mon Nov 06, 2006 8:22 am 
Newbie

Joined: Mon Oct 23, 2006 6:54 am
Posts: 15
Hibernate version:
Hibernate 3.2.0
tools 3.2 beta 8
Name and version of the database you are using:
MSSQL 2000
weblogic mssqlserver4v65.jar jdbc driver

hi,

I use hibernatetool to reverseeng. all hbm and java files....
I have a table which has a many to many relationship with table b 3 times with 3 diffrent "many to many relationship"-table.

Table a -> Table_1_a_And_b <- Table B
Table a -> Table_2_a_And_b <- Table B
Table a -> Table_3_a_And_b <- Table B

My problem is that the setter methods gets the same name...
eg..

a.setB(Set b)
a.setB_1(Set b)
a.setB_2(Set b)

Is there a way to override the name of the setter methods?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 8:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
are you *completely* sure you are using b8 ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 8:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
...arh you have too since manytomany weren't supported properly before in reveng.

DefaultReverseEngineeringStrategy should handle this, but apparently we don't detect that the references is non-unique.

Report it in jira - thanks.

workaround:
implement your custom revengstrategy and override foreignKeyToManyToManyName to make it return what you want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 9:47 am 
Newbie

Joined: Mon Oct 23, 2006 6:54 am
Posts: 15
You mean extending the DelegatingReverseEngineeringStrategy class?

tnx.. :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 9:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes that is the recommended way of writing a custom reveng strategy.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 5:18 am 
Newbie

Joined: Mon Oct 23, 2006 6:54 am
Posts: 15
I got what I wanted by using the middletable.getName...

eg.
public String foreignKeyToManyToManyName(ForeignKey fromKey, TableIdentifier middleTable, ForeignKey toKey, boolean uniqueReference) {
return super.foreignKeyToManyToManyName(fromKey,middleTable,toKey, true)+"For"+middleTable.getName();
}

I tried to force uniqueReference=false but that did not include the middletable when foreignKeyToManyToManyName was called. My problem is that table A and b has same primary keys in the middletabel 1, 2 and 3...

Table a -> Table_1_a_And_b <- Table B
Table a -> Table_2_a_And_b <- Table B
Table a -> Table_3_a_And_b <- Table B

...and that caused the setter method to be same name no mather wath value I set the uniqueReference to. I need the middletable name to get it unique.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 6:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - which will probably be what we should change it to when the isUnique detection get fixed.

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