-->
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: An entity with a static list
PostPosted: Thu Aug 16, 2007 11:49 am 
Newbie

Joined: Thu Aug 16, 2007 11:41 am
Posts: 2
Hi,

I have an mapped entity like this:

Code:
class Foo
{
  public virtial int Id ...
  public virtual IList<string> SomeStrings {...}
}



I would like the SomeStrings property to return "static" data, that is the same data for every instance of Foo, and for that data to come from a table in the database with a single value column (i.e. no FK relation with Foo's Id).

Is this possible? Can I do this in Foo's mapping file?

Cheers,

John


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 12:50 pm 
Beginner
Beginner

Joined: Fri Sep 08, 2006 2:55 am
Posts: 21
Yeah we want to do exactly the same thing. We have tables in the database with static/reference data, for example a list of countries. We want these to be automatically read into the domain class using a mapping but we haven't found a way to do it yet....


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 19, 2007 2:55 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Why don't you just have the function (property) run a HQL/Criteria query and store that in a static private variable. Do a null check when it is accessed..the first time it is hit will the only time the query is run since you are storing it in a static variable.
I don't like this kind of design as I'd push this kind of thing into its own object but would that work?

Mike

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 20, 2007 4:59 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 2:55 am
Posts: 21
That is essentially what we are doing but we would far prefer to be able to specify that we need all the rows from a table in the HBM file. This would give us a lot more flexibility in our designs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 22, 2007 4:44 am 
Newbie

Joined: Thu Aug 16, 2007 11:41 am
Posts: 2
colinjack wrote:
That is essentially what we are doing but we would far prefer to be able to specify that we need all the rows from a table in the HBM file. This would give us a lot more flexibility in our designs.


Yeah, exactly!

If there is no way to do this in NHibernate, do you think it would be OK to raise a feature request?


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.