-->
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.  [ 13 posts ] 
Author Message
 Post subject: FK1_GROUP_USER_ID in Category.hbm.xml
PostPosted: Mon Jan 31, 2005 7:13 pm 
Regular
Regular

Joined: Fri Jan 28, 2005 3:11 am
Posts: 81
The Category.hbm.xml makes a reference to FK1_GROUP_USER_ID, which is not part of the schema. Is that an error?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 7:43 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Where?


Top
 Profile  
 
 Post subject: oops, I meant FK1_CATEGORIZED_ITEM_ID
PostPosted: Tue Feb 01, 2005 12:01 pm 
Regular
Regular

Joined: Fri Jan 28, 2005 3:11 am
Posts: 81
oops, I meant FK1_CATEGORIZED_ITEM_ID

as in <key foreign-key="FK1_CATEGORIZED_ITEM_ID">
<column name="CATEGORY_ID" not-null="true" length="16"/>
</key>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 7:52 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read up on what the foreign-key attribute does.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 4:32 pm 
Regular
Regular

Joined: Fri Jan 28, 2005 3:11 am
Posts: 81
I read the documentation at http://www.hibernate.org/hib_docs/reference/en/html/

but all I could find about the foreign-key attribute was this:

foreign-key foreign_key_name specifies the name of the foreign key constraint generated for an association, use it on <one-to-one>, <many-to-one>, <key>, and <many-to-many> mapping elements. Note that inverse="true" sides will not be considered by SchemaExport.

Is there another place I can read up on this so I can understand why this key seems to be invisible to the schema?

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 6:17 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Its just a name. If you don't use the attribute, the FK constraint will get a different, auto-generated name. Its not about turning the constraint on or off.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And, if this isn't obvious, this is only relevant if Hiberante's SchemaExport generates the database schema and the constraints. It doesn't matter much if you have an existing schema.


Top
 Profile  
 
 Post subject: my schema was generated, that's why I am puzzled
PostPosted: Thu Feb 03, 2005 6:23 pm 
Regular
Regular

Joined: Fri Jan 28, 2005 3:11 am
Posts: 81
Well, that's exactly why I am puzzled: I generated my caveat emptor schema automatically using the "exportddl" ant build script target that you provided in the distribution. It worked well, but that foreign key does not appear anywhere on the DDL that got generated. I thought the generated DDL should be based on my mappings.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 3:10 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Because its inverse="true". You just pasted that part of the documentation...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 11:40 am 
Regular
Regular

Joined: Fri Jan 28, 2005 3:11 am
Posts: 81
I am confused. Then why is that attribute there? Also, I've read about the inverse=true in the documentation and all that but didn't realize that would be relevant to foreign key not being considered. Please elaborate or send me a link to the info that would clear up my understanding.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 05, 2005 12:23 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I'm not going to discuss this further, everything has been answered several times in this thread (and as I said, you already pasted the piece of documentation that is relevant). If you absolutely can't live with it, remove the attribute. It makes no difference. It makes a difference if you put the inverse="true" on the other side of the association, as described in the book.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 05, 2005 12:24 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Another tip: consider reading up on database basics to understand what the difference between a constraint and a constraint name is, you still don't seem to get that part.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 05, 2005 11:45 pm 
Regular
Regular

Joined: Fri Jan 28, 2005 3:11 am
Posts: 81
I can live with it just fine, all I was asking is what effect it has, since it never made it into the generated ddl (and, yes, I know the difference between constraint name and constraint and nevertheless, my knowledge indicates that constraint names DO make it into the ddl.) Now, if your answer is: it would have an effect had the attribute on the other side of relationship been set to inverse="true" - that's a perfectly good answer - all you have to do is say just that. The expression of impatience, I believe, is unwarranted.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.