-->
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: Mapping reference data
PostPosted: Thu Sep 14, 2006 12:46 pm 
Newbie

Joined: Mon Jul 18, 2005 7:45 am
Posts: 16
We are currently refactoring an existing domain model class library to use NHibernate (amongst other things).

One of the things that the old domain objects did was to load reference values from the database in the background - e.g. a 'RiskProfile' object calculates a weight and then 'looks up' a risk profile category (a string) based on this weight directly from the database. Obviously, we don't want to take this approach since separation of the domain and the persistence layers was a key objective in the redesign.

As an alternative, we are currently 'injecting' an in-memory collection of reference data items into the object so that it can do it's own look up. This seems to work OK and the injection can probably be made to be a part of the repository logic.

It did get us thinking though, that it'd be nice if there was a way define a mapping in the HBM file that would load all the rows from a particular reference data table as a collection belonging to another domain object. There is no relationship between the underlying tables, so the normal NHibernate associations don't seem to apply. Is there any way of doing this purely with an NHibernate mapping? Does anybody have any other suggestions for how to deal with reference data of this sort?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 21, 2006 3:25 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
I agree. WHen I started out using Wilson's ORMapper, he had a Lookup element in his mapping files that made it a cinch to do these kinds of things.
I assume that the reason for not having this is exactly as you said...seperation of concerns.

_________________
If this helped...please remember to rate it!


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.