-->
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: Key Value Mapping
PostPosted: Mon Feb 02, 2004 10:56 pm 
Newbie

Joined: Wed Sep 03, 2003 9:08 am
Posts: 18
Is there any way to map the fields of my java object to db table in key- value format.

For ex, in my table table1, I have just two fields.
Name Value

and I have two rows as

Name Value
name1 value1
name2 value2


In my java object I have getter and setter methods like getName1() and getName2()..

How do I map the objects' fields to the table's rows?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 5:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
But you'll have only 1 table per instance in your DLL !

Anyway the easiest way is to map you object with a Map (key, value)
And add unmapped getters and setters to access the appropriate map key

Code:
/** mapped collection */
private Map getMap() {...}

...

public getName1() {
  return getMap().get("name1");
}

public setName1(String name1) {
  return getMap().put("name1", name1);
}

_________________
Emmanuel


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.