How map on a xml the Composite Pattern in Hibernate?



I have an abstract class called Criteria and two sublclasses: SimpleCriteria and ComposedCriteria both extending from Criteria. ComposedCriteria inself has two fields (criteria1, criteria2) of type Criteria. I mean.. it is a composite design pattern.


I want to map on a Hibernate xml file but I have some troubles giving the criteria1 and criteria2 types. When I use the type="Criteria" it tells me that can´t instantiate Criteria (because it´s abstract of course).


This is my actual xml:





<subclass name="ComposedCriteria" discriminator-value="Composed">

<property name="criteria1" type="Criteria">
<column name="ID_CRITERIA1" />
</property>

<property name="criteria2" type="Criteria">
<column name="ID_CRITERIA2" />
</property>

</subclass>




Well, do you have an idea of how to deal with this?


No comments:

Post a Comment