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