-->
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.  [ 4 posts ] 
Author Message
 Post subject: Foreign keys definitions in reveng xml
PostPosted: Fri Nov 10, 2006 12:33 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
I was wondering about the justification for a certain limitation/restriction in Hibernate tools. In the hibernate.reveng.xml file, the documentation states that in the <foreign-key> the constraint-name is required. Firstly, why does the dtd not reflect this requirement? Secondly, why is this a required element in the first place? The OverrideBinder.bindForeignKeys method calls Table.createForeignKey, which will generate a unique(?) FK name if the constraintName is not specified. Subsequent to this call, prior to processing the directives embedded in the <foreign-key> element, it checks to see if the constraint-name was specified before processing the embedded directives. So, basically, if you do not specify the constraint-name, it generates the FK anyways and then promptly ignores the embedded directives (e.g. <set exclude="true"/>).

I came across this problem in my reverse engineering when adding foreign keys in the hibernate.reveng.xml file, where I did not realize that the constraint-name was required and was baffled as to why it was ignoring my foreign-key directives. Unfortunately, the DBAs left out a bunch of foreign keys for some unknown reason, and I have 400 tables to map, adding about 1000 foreign keys. Most of these FKs are not mapped bidirectionally, so I wanted them to ignore the <set> side of things in most circumstances. But I really do not want to have to put in 1000 made up, do-nothing foreign key constraint names (FK0001, FK0002, FK0003, etc., ad infinitum, ad nauseum) when Table.createForeignKey will do it for me.

Simple fix/enhancement: Change documentation to state that if the constraint-name is not specified, a generated constraint-name will be supplied. Remove/enhance the StringHelper.isNotEmpty(constraintName) check in the OverrideBinder.bindForeignKeys method.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 12:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the constraint name is used for naming stuff if there is duplicate names.

...put any irregularities into our jira.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 1:10 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
The only irregularity that exists is that the foreign-key directives are silently ignored when the constraint-name is not specified. Since the JDBCReader already throws a MappingException when duplicate foreign key constraint names are specified, I just did not see the purpose of requiring an essentially arbirtrary constraint-name when Table.createForeignKey will create a functional constraint name for you if you do not specify one.

I can JIRA the request for enhancement if you so desire. At least this forced me to dig down into the JDBCReader and OverrideBinder to see what happens in there. Nice stuff! :D


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 1:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
report in jira otherwise i forget...

one reason for requiring them is to be able to detect wether it is a duplicate or not...anyhow ..into jira

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