-->
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.  [ 15 posts ] 
Author Message
 Post subject: how to fetсh a Table by TableIdentifier?
PostPosted: Thu Dec 28, 2006 9:51 am 
Newbie

Joined: Wed Dec 27, 2006 10:03 am
Posts: 19
Hi there!

I intend to write custom reverse engineering strategy class extending

Code:
org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy


My question is: how do I get a correct
Code:
org.hibernate.mapping.Table
object by
Code:
org.hibernate.cfg.reveng.TableIdentifier
inside the method
Code:
org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy.isForeignKeyCollectionInverse(...)
?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 28, 2006 3:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
What do you need it for ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 30, 2006 4:58 pm 
Newbie

Joined: Wed Dec 27, 2006 10:03 am
Posts: 19
just wanted to fix many-to-many annotation generating


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 31, 2006 8:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
but what do you need the Table object for ? what info are you missing ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 01, 2007 1:52 pm 
Newbie

Joined: Wed Dec 27, 2006 10:03 am
Posts: 19
Well, If I had a Table instance, I could pass it to method isManyToManyTable(Table) to determine whether it's a many-to-many join table


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
fair enough - put it in jira with a link to this posting.

...but what would you use in addition to decide which side get's to be inverse and which side should not ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:32 am 
Newbie

Joined: Wed Dec 27, 2006 10:03 am
Posts: 19
max wrote:
fair enough - put it in jira with a link to this posting.


done! http://opensource.atlassian.com/project ... se/HBX-846

max wrote:
...but what would you use in addition to decide which side get's to be inverse and which side should not ?


well, for two-columns join tables there is a simple solution.

Code:

boolean isForeignKeyCollectionInverse(String name, TableIdentifier fkTable, List columns, TableIdentifier fkRefTable, List refColumns))
{
      Table table = getTableByTableId(fkTable); // this needs to be implemented
      if(isManyToManyTable(table))
      {
         if (table.getColumn(0).getName().equals(name)) {
            return true;
         }         
         if (table.getColumn(1).getName().equals(name)) {
            return false;
         }         
      }
      return true;
 
}



Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
For now you can look the table up through the Configuration object.

But in the next release i'll might consider changing the api to be an Table instead of TableIdentifier since at the time the method is called we should have the complete table...but need to check that.

Put in jira so we don't forget it - thanks.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:47 am 
Newbie

Joined: Wed Dec 27, 2006 10:03 am
Posts: 19
max wrote:
For now you can look the table up through the Configuration object.

But in the next release i'll might consider changing the api to be an Table instead of TableIdentifier since at the time the method is called we should have the complete table...but need to check that.

Put in jira so we don't forget it - thanks.



Jira task created.

Can you point me to how do I obtain a Configuration object from within DefaultReverseEngineeringStrategy methods?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 02, 2007 6:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sorry I spoke too fast; you can't do that because it is what the reverse engineering strategy is used to built thus it is not correct until later on.

But we could probably consider giving access to a partial/other api to access the (until now) found tables etc.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 4:54 am 
Newbie

Joined: Wed Dec 27, 2006 10:03 am
Posts: 19
Hi Max,

The task I've created is still unassigned for some reason. Can you please assign it to a proper person? Thanks!

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 4:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i've assigned it to a release.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 3:06 am 
Beginner
Beginner

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

I facing the same problem. May I know how can I get the table object ?

This is because I need to get the first column of the table. I found out the tableobj.getColumns can do that. Any other API I can call to get this info ?

Thanks in advance. :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 11:36 am 
Newbie

Joined: Fri Jul 28, 2006 10:53 am
Posts: 15
Any updates on this? The bug still hasn't been fixed, and even more annoyingly the method isForeignKeyCollectionInverse is still just always returning true. That makes the reverse engineering of many-to-many relationships useless unless the mapping XML/annotations are manually edited afterwards (not really an option for us).

It would seem relatively simple to fix to! Why the delay? If I submitted a patch for it, would you put it in?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 12, 2007 9:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
patches always increases the chances of inclusion - so feel free ;)

With respect to it being "trivial" then it is not completely trivial since this method can be called before all tables have been collected (as far as I *remember*)

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