-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: verschiedenen Vererbungsstategien mischen
PostPosted: Tue Nov 02, 2010 10:59 am 
Newbie

Joined: Tue Nov 02, 2010 9:26 am
Posts: 2
Hallo,
Laut Hibernate Docs kann man anhand SecondaryTable die verschiedenen Vererbungsstategien mischen.
Leider bekomme ich Unique Constaints Violation Exception,da Hibernate bei Anlegen zum Beispiel ein SubClass2 zwei Insert in der Tabelle SubClass1 ausführt.
Hat jemand eine Idee,woran es liegen kann? und wie kann man das verhindern? Oder wie man das mischen Vererbungsstategien anderes lösen kann?


SupperClass (Eigene Tabelle= SupperClass)
.........|------------------SubClass1 (Eigene Tabelle= SubClass1)
....................................................|------------------SubClass2 (Keine Eigene Tabelle ( SubClass1))
.......................................................................................... |------------------SubClass3 (Keine Eigene Tabelle ( SubClass1))


Code:
@Entity
@Table(name = "SupperClass")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="DC",discriminatorType=DiscriminatorType.INTEGER)
@DiscriminatorValue(value = "0")
class SupperClass{
}

-------------------------
Code:
@Entity
@DiscriminatorValue(value = "1")
@SecondaryTable(name = "SubClass1",pkJoinColumns = {
        @PrimaryKeyJoinColumn(name = "ID", referencedColumnName = "ID")})
public class SubClass1 extends SupperClass {
   @Column(table = "SubClass1")
    private String attribut1;
}


-------------------------
Code:
@Entity
@DiscriminatorValue(value = "2")
@SecondaryTable(name = "SubClass1",pkJoinColumns = {
        @PrimaryKeyJoinColumn(name = "ID", referencedColumnName = "ID")})
public class SubClass2 extends SubClass1{
@Column(table = "SubClass1")
    private String attribut2;
}


-------------------------
Code:
@Entity
@DiscriminatorValue(value = "3")
@SecondaryTable(name = "SubClass1",pkJoinColumns = {
        @PrimaryKeyJoinColumn(name = "ID", referencedColumnName = "ID")})
public class SubClass3 extends SubClass2{
@Column(table = "SubClass1")
    private String attribut3;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.