-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using <map>, the column in <index> is clean when
PostPosted: Fri Jun 03, 2005 8:32 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
Say I have a Department object, which has a "map", contains multiple Users.

The <index> will be each User's "ID" column, which will be used as "key" for the IDictionary type.

The <key> will be each User's "DepartmentID" column.

If I remove a User from the Department, I just remove the user object instance from the IDictionary. When I use session.save() to save the owner object -- Department, it cleans the "DepartmentID"' column of that user (which is expected), it also cleans the "ID" column (which it should not be clean, because the user's ID shall be kept forever, and actually, it's not null column.


Top
 Profile  
 
 Post subject: The mapping I am using:
PostPosted: Fri Jun 03, 2005 8:51 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
Code:
<map name="childCodes" table="CODE_DESC" sort="natural" lazy="true" cascade="save-update">
         <key column="CODE_TYPE_ID" />
         <index column="CODE" type="AnsiString" />
         <one-to-many class="BMO.BookCredit.APMSCode.AbstractAPMSCode, BMO_BookCredit_DataObjects" />
      </map>


If I use <many-to-many>, the remove will delete the whole record. If I use <Composite-element> the remove doesn't do anything[/code]


Top
 Profile  
 
 Post subject: I don't understand
PostPosted: Tue Jun 07, 2005 2:13 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
It seems (N)Hibernate enforce a seperate column for <map>'s <index>.

That <index> is the "Key" of IDictionary, usually, it is the Value's identity or name property.

Say, Teacher vs. Students, many-to-many relationship. I'd like to have a Hashtable in Teacher class, which contains all the Students belont to one teacher. The Hashtable's key is the student's name or ID, the value the the object instance of the student, sure, the student object still have name and ID property, which get from the DB.

Why (N)Hibernate enforce <index> has to be a seperate column?


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