Hi!
After searching for two days without success I finally decided to post this topic.
I want to substitute the following mapping that uses dynamic entities (entity-name) with annotations.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field">
<class name="pojo.Person">
<id name="id" type="long">
<generator class="native"/>
</id>
<property name="name"/>
<bag name="alive" cascade="all-delete-orphan">
<key column="person_id" not-null="true" update="false"/>
<one-to-many entity-name="Alive"/>
</bag>
</class>
<class name="util.BBTemporalWrapper" entity-name="Alive">
<id name="id" type="long">
<generator class="native"/>
</id>
<property name="value" type="boolean"/>
<property name="validityInterval" type="org.joda.time.contrib.hibernate.PersistentInterval">
<column name="validityStart"/>
<column name="validityEnd"/>
</property>
<property name="recordInterval" type="org.joda.time.contrib.hibernate.PersistentInterval">
<column name="recordStart"/>
<column name="recordEnd"/>
</property>
</class>
</hibernate-mapping>
Person:
Code:
public class Person {
private Long id;
private String name;
private Collection<BBTemporalWrapper<Boolean>> alive = new LinkedList<BBTemporalWrapper<Boolean>>();
public Person() {
}
public WrappedBitemporalProperty<Boolean> getAlive() {
return new WrappedBitemporalProperty<Boolean>(alive);
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
}
BBTemporalWrapper:
Code:
public class BBTemporalWrapper<V> {
private Long id;
private V value;
private Interval validityInterval;
private Interval recordInterval;
...
}
The Alive-Entity is not needed as a class.
Can someone give me a hint, how to use the BBTemporalWrapper-Class as an entity that is used for different tables by using annotations?
Thanks
Fabian