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?
|