Hello,
I have posted this in ther german forum but there comes no reply -- so i give it here another try . . .
I am working with Hibernate-Annotations and after some smaller problems i got further and further ;-)
But there is a bigger problem i couldnt solve yet. There is a inheritence structure I could not set in annotations yet.
I have got some classes:
Code:
----------
| News |
----------
^
|
|
----------------------------
| AbstractAdHocNews |
----------------------------
^ ^
| |
| |
---------- ----------
| SMS | | Email |
---------- ----------
SMS and Email are extended AbstractAdHocNews which should be mapped within a SINGLE_TABLE called AdHocNews. Furthermore, AbstractAdHocNews and News should be in two different tables. So I marked the inheritence strategy of News with TABLE_PER_CLASS. But there should remain a reference of all AbstractNews in the table News. I tried to use @MappedSuperClass: This created two tables as I want, but all attributes of the superclass News were in the AbstractAdHocNews table as well. I want it like this:
Code:
News
----------------------------------
|id | news_att1 | news_att2 | ... |
----------------------------------
AbstractAdHocNews
--------------------------------------------
|id | discr | adhoc_att1 | adhoc_att2 | ... |
--------------------------------------------
"discr" is the discriminator value, e.g. "sms" or "email".
My result for now is that I have got no AbstractAdHocNews table. I get a SMS table and a Email table. Isnt it possible to override inheritence strategys?
My Mapping Annotation Signatures are as the following
## News ##
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class News implements Serializable {
. . .
}
## AbstractAdHocNews ##
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="NEWS_TYPE",discriminatorType=DiscriminatorType.STRING)
public abstract class AbstractAdhocNews extends News {
. . .
}
## SmsNews ##
@Entity
@DiscriminatorValue("SMS_NEWS")
public class SmsNews extends AbstractAdhocNews {
. . .
}
## EmailNews ##
@Entity
@DiscriminatorValue("EMAIL_NEWS")
Thanks for your help
Henning
[/b]