Hi,
I need help with Hibernate 3.2. CR1 and I hope that you can help me.
I need to implement following inheritance tree using Hibernate annotation:
Code:
(1) PersistentData::PeriodDependentMasterData::NetRegion
(2) PersistentData::PeriodDependentMasterData::Carrier::ExternalCarrier
(3) PersistentData::PeriodDependentMasterData::Carrier::UICCarrier
For (1) inheritance leg I'm using the InheritanceType.JOINED strategy.
For the legs (2) and (3), starting from Carrier class, I like to use the
InheritanceType.SINGLE_TABLE strategy. See following section:
Code:
@MappedSuperclass
abstract class PersistentData implements Serializable {
}
@Entity
@Table(name="PERIODDEPENDENDMASTERDATA")
@Inheritance(strategy=InheritanceType.JOINED)
abstract class PeriodDependentMasterData extends PersistentData {
}
@Entity
@Table(name="NETREGION")
@PrimaryKeyJoinColumn(name="ID")
public class NetRegion extends PeriodDependentMasterData {
}
@Entity
@Table(name="CARRIER")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="MAPPINGTYPE_ID",discriminatorType=DiscriminatorType.INTEGER)
@DiscriminatorValue("10")
public abstract class Carrier extends PeriodDependentMasterData {
}
@Entity
@DiscriminatorValue("11")
public class ExternalCarrier extends Carrier {
}
@Entity
@DiscriminatorValue("13")
public class UICCarrier extends Carrier {
}
Because this code doesn't work for me I like to ask you following questions:
1. Can I mix InheritanceType.SINGLE_TABLE and InheritanceType.JOINED strategies?
2. If yes then what is wrong with my code?
3. Where can I find tutorials or sample code for inheritance strategy minxing? I found only following page: http://www.hibernate.org/hib_docs/v3/re ... tance.html
Regards
Christoph