-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to fit standard OO practice in NH
PostPosted: Sat Nov 05, 2005 6:04 pm 
Newbie

Joined: Sat Nov 05, 2005 5:58 pm
Posts: 2
Location: Milano, Italy
Hello All,
I'm a developer just landed to the world of NHibernate and I'm trying to understand it better...

At the moment I'm building my first real application using it and I just came into 2 problems: how can I use my usual standard business object architectur in NH?
I usually use strongly-typed collection and the special-case pattern, but can't understand how to convert these 2 practices for use with NH.

I made a search on this forum or over the internet but just found questions without an answer...
seems strange that nobody is using this kind of "standard" approach in developing NH domain model library.

Thank you
Simone


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 06, 2005 6:14 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
There's no support for strongly-typed collections currently. Ayende Rahien recently created a library to support generic collections with NHibernate. As for the special-case pattern, this could probably be implemented using a custom persister... (overriding Instantiate method).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 06, 2005 11:42 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
You may wrap collections in a set of methods (like "Add(XXX)", "XXXCount", "RemoveXXXAt()", etc.)
Here is an example: Factory and collection design

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 8:05 am 
Newbie

Joined: Sat Nov 05, 2005 5:58 pm
Posts: 2
Location: Milano, Italy
Thank you
I found out a possibile solution...
basically I make 2 properties
one is accessed by NH and the other is accessed by the domain model
and both refers to the same IList as storage.

Simo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 5:23 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
I follow alot of the patterns mentioned in Domain Driven Design by Eric Evans. One thing I have being doing lately is implementing an interface which I call a smart collection. I then basically have an Adapter for the Smart collection interface to wrap the actual collection, IList or ISet.

The smart collection contains all of the add, remove, insert operations, and also a FindById operation. Smart Collection can check business logic before access to the real collection is allowed. Having and Adapter around the real collection also gives me the ability to use some of NHibernates more advanced features such as collection filters.


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