Salut à tous,
Voici pour tous les GEEKs Hibernate, j'ai problème d'héritage avec principalement le stratégie: "InheritanceType.JOINED". Ci-joint les mes différentes classes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 @Entity @javax.persistence.Table(name= "EMP", schema= "edu") @Inheritance(strategy= InheritanceType.JOINED) @DiscriminatorColumn(name= "EMP_TYPE", discriminatorType= DiscriminatorType.STRING) public abstract class Employee { @Column(name = "NAME_") private String name; @Column(name = "S_DATE") @Temporal(TemporalType.DATE) private Date startDate; @Id private long id= System.currentTimeMillis(); public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getStartDate() { return startDate; } public void setStartDate(Date startDate) { this.startDate = startDate; } public String toString() { return "Employee id: " + getId() + " name: " + getName(); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 @Entity @javax.persistence.Table(name= "PT_EMP", schema= "edu") @DiscriminatorValue("3") public class PartTimeEmployee extends Employee { @Column(name = "H_RATE") private float hourlyRate; public float getHourlyRate() { return hourlyRate; } public void setHourlyRate(float hourlyRate) { this.hourlyRate = hourlyRate; } public String toString() { return "PartTimeEmployee id: " + getId() + " name: " + getName(); } }Comme vous pouvez le constater, il s'agit d'un héritage assez simple. Mais mon problème est le suivant. Dès que passe ma stratégie d'héritage à "InheritanceType.JOINED", la colonne "EMP_TYPE" n'est pas générée. Mais si j'utilise les deux autres stratégies, tout se passe nikel.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 @Entity @javax.persistence.Table(name= "FT_EMP", schema= "edu") @DiscriminatorValue("2") public class FullTimeEmployee extends Employee { private long salary; private long pension; public long getPension() { return pension; } public void setPension(long pension) { this.pension = pension; } public long getSalary() { return salary; } public void setSalary(long salary) { this.salary = salary; } public String toString() { return "FullTimeEmployee id: " + getId() + " name: " + getName(); } }
Quelqu'un aurait-il une idée?
Voici ma config. technique.
Hibernate3 --> 3.6.4
Base postgres --> 9.0
name : PostgreSQL
version : 9.0.1
major : 9
minor : 0
Driver ->
name : PostgreSQL Native Driver
version : PostgreSQL 8.4 JDBC3 (build 702)
major : 8
minor : 4
Jar -> postgresql-8.4-702.jdbc3.jar
Bon voilà tout. Je suis preneur de tout proposition.






Répondre avec citation
Partager