Bonjour a tous j'ai un schemas comme ceci
1 2
|
institution | union | federation | confederation |
union, federation et confederation heritent de institution,
une union peut avoir plusieurs institutions,
une federation plusieurs unions et une confederation plusieurs confederations ce qui nous ammene a ce mapping :
AbstractEntity
1 2 3 4 5
| @MappedSuperclass
public abstract class AbstractEntity {
protected Long id;
//getters & setters |
institution
1 2 3 4 5 6
|
@Entity
@Table(name = "******", catalog = "*****")
@Inheritance(strategy = InheritanceType.JOINED)
public class Institution extends AbstractEntity implements java.io.Serializable {
private Union union; |
Union
1 2 3 4 5
| @Entity
@Table(name = "*****", catalog = "*****")
@PrimaryKeyJoinColumn(name="id")
public class Union extends Institution implements java.io.Serializable {
private Federation federation; |
Federation
1 2 3 4 5
| @Entity
@Table(name = "*******", catalog = "*****")
@PrimaryKeyJoinColumn(name="id")
public class Federation extends Institution implements java.io.Serializable {
private Confederation confederation; |
Confederation
1 2 3 4
| @Entity
@Table(name = "*****", catalog = "***")
@PrimaryKeyJoinColumn(name="id")
public class Confederation extends Sfd implements java.io.Serializable { |
Le probleme c'est que quand j'execute j'ai un
org.hibernate.WrongClassException : Object with id: 2 was not of the specified subclass: com.***.Union (loaded object was of wrong class com.***.Federation)
PS j'ai un tableau de ce type
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
+-----------+ +------------+ +-------------+ +-------+
| Instit___| | Union___| | Federat | | Conf |
+-----------+ +------------+ +------------+ +-------+
| id |union|*| |id | federa| |id | confed| |id |
+-----------+ +-------------+ +-------------+ +----+
| 1 | NULL| |___________| |_________| | 1 |
| 2 | NULL| | 2 | 2 | | 2 | 1 | -------
| 3 | NULL| | 3 | NUL | ---------------
| 4 | NULL| | 4 |NUL |
| 5 | 3 __| |________|
| 6 | 4__|
| 7 | NULL|
+------------+ |
Petite specificite : l'institution numero 2 est en meme temps une union et une federation.
Partager