Bonjour,
j'ai un soucis avec hibernate (j'utilise la 3.2.6.ga avec les annotations 3.3.1.GA).
J'ai plusieurs entités :
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
43
44
45
46
47
48
49
50 @Entity @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public class Person implements Serializable { private static final long serialVersionUID = 1L; private Long id; private Civility civility; private String firstName; private String lastName; @Id @GeneratedValue(strategy=GenerationType.TABLE) public Long getId() { return id; } public void setId(Long id) { this.id = id; } @ManyToOne @JoinColumn(nullable=false) public Civility getCivility() { return civility; } public void setCivility(Civility civility) { this.civility = civility; } @Column(nullable=false) public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } @Column(nullable=false) public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } }
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 @Entity public class User extends Person implements Serializable { private static final long serialVersionUID = 1L; private String login; private String password; @Column(nullable=false) public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } @Column(nullable=false) public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }Et quand je lance des tests from scratch, toutes mes tables se créent bien, j'ai des insertions qui fonctionnent (Civility par exemple), mais lors de l'insertion d'un Admin ça marche pô
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 @Entity public class Admin extends User implements Serializable { private static final long serialVersionUID = 1L; }
Hibernate va bien chercher la séquence qui correspond bien :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Admin admin = new Admin(); admin.setCivility(civilityDao.getByCode(Civility.Code.MR)); admin.setFirstName("toto"); admin.setLastName("toto"); admin.setLogin("rmk"); admin.setPassword("5f4dcc3b5aa765d61d8327deb882cf99"); userDao.saveOrUpdate(admin);
Mais l'insertion ne se fait pas, et j'ai pas d'erreur...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 SQL - select sequence_next_hi_value from hibernate_sequences where sequence_name = 'Person' for update
Merci de votre aide...
Partager