-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping for collection of collections (IDictionary of ISet)
PostPosted: Thu Jun 08, 2006 4:35 am 
Newbie

Joined: Thu May 04, 2006 4:23 am
Posts: 16
Location: Germany
Hi,

Problem 1:
the NH docu has the statement:
Quote:
"no collections of collections may be mapped."


But there are some cases of "collections of collections", for which a mapping would be helpful and possible.

Example: class City has the property:

Code:
    IDictionary<IGoodsType, ISet<IShop> > shopsByGoods


which could be used like:

Code:
Set<IShop> void findShop(IGoodsType goodsTyp) {
    return shopsByGoods[goodsTyp];
}


The table has the schema:

Code:
table Tab_Shop
-----------------------
id             | int - primary key
ref_id_city    | int
ref_id_goods   | int
name           | string
opening_hours  | string
address        | string
rating         | int


How can the property "shops" be mapped to table Tab_Shop?

+++++++++++++++++++++++++++++

Problem 2:
Class City should have another (but read-only) property

Code:
ISet<IShop> allShops {
    get { return shopsByGoods.Values; }
}


which returns all shops the city (i.e. for any goods type).

Problem 3: (deferred)

Later on, the goods types could be arranged in a tree, with the (most general) goods-type "all" as root.
But that is to complicated and not required for the moment.


Thank you for your interest,
Mick


P.S.
I know that the used data base schema (table Tab_Shop) restricts the usage of the IDictionary: every shop may be assigned to almost one goods type.
So the realized concept is that of a "partitioning" of the set of shops.
But when using the IDictionary for read-only purposes there is no restriction.

In .NET Framework I found a class/interface like an IDictionary where you can add elements with an identifier property.
The elements of this special-dictionary can then asked by giving the id-value as the key-value, like in:
Code:
shopsByGoods[goodsTyp]

Problem: I don't remember the name of the class and can't find it again in the .NET docu.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.