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: Map arbitrary objects inside a map as first class properties
PostPosted: Wed Nov 24, 2010 1:03 pm 
Beginner
Beginner

Joined: Wed Jul 01, 2009 8:11 am
Posts: 34
Hi,

i have an object which has a collection of other different objects, it is used for AOP inter-type declaration like style to compose objects.

For example there is class A which provides means to add arbitrary objects to it:
Code:
class Owner {
   private Map<String, Object> objects = new HashMap<String, Object>();
   public void addObject(String name, Object object) {
      this.objects.put(name, object);
   }
}


And now we can add to it other objects that add some data. For example there is a class O1:
Code:
class O1 {
   private String name;
   // getter and setter for name
}

And there is a class O2:
Code:
class O2 {
   private Set<Long> prices;
   // getter and setter for name
}


Both of them now can be added to instances of class A:
Code:
A a = new A();
a.addObject(new O1());
a.addObject(new O2());


What i want to do now is to get these objects in the collection persisted. I want to do this like they were ordinary properties of the class:
Code:
<hibernate-mapping>
   <class name="A">
      <property name="name"/>
      <set name="prices">
         ...
      </set>
   </class>
</hibernate-mapping>

I want to do it that way so that these properties do appear in the same table as the properties of class A, because virtually O1 and O2 belong to class A.

Can this be done?

Best regards


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.