-->
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: Saving specific data from maps (according to specific keys)
PostPosted: Sun Feb 15, 2004 1:34 pm 
Newbie

Joined: Sun Feb 15, 2004 1:17 pm
Posts: 3
Hi,
I am considering into utilizing hibernate in a new project I'm working on...

I have a dynamic class which is similar to a map as it can store dynamic values, however when I write it into the DB I only want to save some specific values out of it.
Code:
// for example my class
public class LikeAMap {

        public void setValue(String name, String value);
        public void getValue(String name);

}

public class mainClass {

      LikeAMap one = new LikeAMap();
      one.setValue("a","important");
      one.setValue("b","doesn't need to be saved");

      LikeAMap two = new LikeAMap();
      two.setValue("a","need to be saved");
      two.setValue("b","runtime garbage");

}


now I want to save all my LikeAMap instances into the DB using hibernate... but I only want to save the values "a", and not values "b".
Is there a way to define such an XML which only saves values of
Value property where key is "a"?


I've snooped around the documentation and couldn't find out if/how can I do this, your help will be much appriciated....
Thanks!
Shahar.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 15, 2004 1:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Probably add private get/set Methods which return the data you want to persist and map them. Can't think of another way right now.


Top
 Profile  
 
 Post subject: that won't help...
PostPosted: Sun Feb 15, 2004 1:43 pm 
Newbie

Joined: Sun Feb 15, 2004 1:17 pm
Posts: 3
Thanks for the quick reply...

However this won't help me, as I don't know in advance what will be the values I wish to save into the DB.
The user of the class will decide it and write it into a configuration file.
I was hoping I could use a hibernate XML mapping file for that job.

Thanks again...
cheers
shahar.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 15, 2004 1:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Well let your getter parse the config file


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2004 4:02 am 
Newbie

Joined: Sun Feb 15, 2004 1:17 pm
Posts: 3
I can't do that, as I don't know how many values out of the map
the user wants to save, so I can't write a single setter.... :(


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.