Bonjour,
J'ai une table dans la BD (Oracle 11g) :
Nom: LOG_ALIM_MAIL
Colonnens : ID_LOG RAW (automatically generated by SYS_GUID() in trigger), ALIMENTATION Number(9), DATE_LOG Date
PK: ID_LOG
FK: ALIMENTATION References ALIMENTATION.ID_ALIMENTATION (Number(9))
LOG_ALIM_MAIL class:
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 public class LogAlimMail implements Serializable { private static final long serialVersionUID = 2243374060845658640L; @Id private Long idLog; private Date dateLog; private Alimentation alimentation; public LogAlimMail() { } public Long getIdLog() { return idLog; } public void setIdLog(Long idLog) { this.idLog = idLog; } public Date getDateLog() { return dateLog; } public void setDateLog(Date dateLog) { this.dateLog = dateLog; } @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }) public Alimentation getAlimentation() { return alimentation; } public void setAlimentation(Alimentation alimentation) { this.alimentation = alimentation; } }
J'ai deux questions :
1. Quand j'essaie d'exécuter la requête suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 public List<LogAlimMail> getAllByIdAlim(Long idAlim) { String request = "select a from LogAlimMail a where a.alimentation.idAlimentation = " + idAlim; Query query = this.getEntityManager().createQuery(request); return query.getResultList(); }
J'ai l'exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: idAlimentation of: administration.LogAlimMail [select a from administration.LogAlimMail a where a.alimentation.idAlimentation = 1]
2. Je ne peux pas faire un mapping JPA entre idLog (Long) et ID_LOG (RAW generated by SYS_GUID()).
Avez-vous des idées ?
Partager