-->
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.  [ 2 posts ] 
Author Message
 Post subject: HashedSet or better alternative ?
PostPosted: Wed Jan 11, 2006 5:19 pm 
Newbie

Joined: Wed Jan 11, 2006 8:24 am
Posts: 5
Hello,

I’m using two business classes with corresponding map files and DB tables on a SQL server.
One class is a “Parent” and the second one is “Child”. This means the parent can have many children (one-to-many relation) and a child has only one parent (many-to-one relation).
The child table on DB has a foreign key pointing to the parent table to match the relation
Many-to-one.
On the Parent class I have a HashedSet() which contains the Child with the following property :
public

Iesi.Collections.ISet ChildList
{
get
{
if (m_ChildList==null)
{
m_ChildList = new Iesi.Collections.HashedSet();
}
return m_ChildList;
}
set { m_ChildList = value; }
}

Everything is working as I want, when I save the parent the corresponding child are also automatically set with the cascade option to the DB, but….

The only small thing I would like to have is an access to the Child object on the Childlist by using a Hashtable and a key, I know the HashedSet is in fact working with a Hashtable but this one is not accessible.
My first question is about this internal HashedSet Hashtable, (InternalDictionary) how are they the keys generated ?
Is it possible to replace Iesi.Collections.HashedSet() by a standard Hashtable (and of course keeping the cascaded update on children ?)., I place the IDictionary interface on my property related to the Hashtable but I got an exception when cascading…
Where and how to specify a key used when we get data (Children) from the DB to fill a simple hashtable ?
May be it exists another way to use Hashtables with NHibernate ?
Another wish is to avoid to add an extra table (kind of join table) on the DB for saving the hashtable…
I’m really starting with NHibernate so I’m afraid to miss something really obvious.

Thanks for your replies…


Top
 Profile  
 
 Post subject: Find the way
PostPosted: Thu Jan 26, 2006 12:40 pm 
Newbie

Joined: Wed Jan 11, 2006 8:24 am
Posts: 5
Finally I was able to do what I want.

Here the way I'm using :

On Parent object Department :

IDictionary m_Rooms = new Hashtable();;

public IDictionary Rooms
{
get { return m_Rooms; }
set { m_Rooms = value; }
}

<map name="Rooms" inverse="true" cascade="all-delete-orphan" lazy="true">
<key column="DepartmentID"/>
<index column="Name" type="String" />
<one-to-many class="Business.Data.Room,Business.Data"/>
</map>

Rem : <index column="Name" type="String" /> Rem : is the Hashtable key (of course is unique for my case)

On Child object Room :


private Department m_department = new Department();

public Department Department
{
get { return m_department; }
set { m_department = value; }
}

<many-to-one name="Department" column="DepartmentID" class="Business.Data.Department,Business.Data" />

It's look this way is not working with a Many-To-Many relation with a join table (with no business object corresponding to the join table) with collection is Ok but Hashtable not...but without error or exception...
I Have to investigate a little bit more :-)


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