-->
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: Load name-value pairs from DB to a java.util.Map property?
PostPosted: Sun Nov 08, 2009 9:32 am 
Newbie

Joined: Sun Nov 08, 2009 8:28 am
Posts: 1
Hello to all Hibernate gurus!

My simple question in short: how to load name-value pairs from DB (no associations to any other table(s)!) to a java.util.Map property of an object.
In more detail:
I have a simple class for holding application configuration with a Map of parameters where key and value are Strings:
public class Configuration {
private Map params; // key and value are of String type
// getter and setter go here
}

I'd like to load params from DB table
create table Config (
Name varchar(64) PRIMARY KEY,
Value varchar(255) NOT NULL);

I know I can create an Entity class e.g. ConfigParam with String properties name and value, map it to Config table and load a collection of such objects
List<ConfigParam> params = session.createQuery("from ConfigParam").list()

But is there a way to load such collection directly to a java.util.Map property of an object?


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.