IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

"could not resolve property" alors qu'elle existe [HQL]


Sujet :

Hibernate Java

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    676
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 676
    Points : 121
    Points
    121
    Par défaut "could not resolve property" alors qu'elle existe
    Bonjour,

    J'ai un problème avec Hibernate tools. J'utilise une base MySQL qui a deux tables : patient et deci qui ont toutes deux un champs id_patient. Dans MySQL j'ai créé une relation avec id_patient pour en faire une clé étrangère (ONDELETE SET NULL et ONUPDATE CASCADE).

    Ensuite je laisse Hibernate me créée le code source de mes classes avec annotation grace à un Hibernate Code Generation.
    Les voici :
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    package objets;
     
    // Generated 22 janv. 2015 11:41:05 by Hibernate Tools 4.0.0
     
    import java.util.Date;
    import java.util.HashSet;
    import java.util.Set;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import static javax.persistence.GenerationType.IDENTITY;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
     
    /**
     * Deci generated by hbm2java
     */
    @Entity
    @Table(name = "deci", catalog = "defib")
    public class Deci implements java.io.Serializable {
     
    	private Integer idDeci;
    	private ModeleDeci modeleDeci;
    	private Patient patient;
    	private String numeroSerie;
    	private Date dateImpantation;
    	private Date dateExtraction;
    	private Set<Patient> patients = new HashSet<Patient>(0);
     
    	public Deci() {
    	}
     
    	public Deci(String numeroSerie) {
    		this.numeroSerie = numeroSerie;
    	}
     
    	public Deci(ModeleDeci modeleDeci, Patient patient, String numeroSerie,
    			Date dateImpantation, Date dateExtraction, Set<Patient> patients) {
    		this.modeleDeci = modeleDeci;
    		this.patient = patient;
    		this.numeroSerie = numeroSerie;
    		this.dateImpantation = dateImpantation;
    		this.dateExtraction = dateExtraction;
    		this.patients = patients;
    	}
     
    	@Id
    	@GeneratedValue(strategy = IDENTITY)
    	@Column(name = "id_deci", unique = true, nullable = false)
    	public Integer getIdDeci() {
    		return this.idDeci;
    	}
     
    	public void setIdDeci(Integer idDeci) {
    		this.idDeci = idDeci;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_modele_deci")
    	public ModeleDeci getModeleDeci() {
    		return this.modeleDeci;
    	}
     
    	public void setModeleDeci(ModeleDeci modeleDeci) {
    		this.modeleDeci = modeleDeci;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_patient")
    	public Patient getPatient() {
    		return this.patient;
    	}
     
    	public void setPatient(Patient patient) {
    		this.patient = patient;
    	}
     
    	@Column(name = "numero_serie", nullable = false, length = 11)
    	public String getNumeroSerie() {
    		return this.numeroSerie;
    	}
     
    	public void setNumeroSerie(String numeroSerie) {
    		this.numeroSerie = numeroSerie;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_impantation", length = 0)
    	public Date getDateImpantation() {
    		return this.dateImpantation;
    	}
     
    	public void setDateImpantation(Date dateImpantation) {
    		this.dateImpantation = dateImpantation;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_extraction", length = 0)
    	public Date getDateExtraction() {
    		return this.dateExtraction;
    	}
     
    	public void setDateExtraction(Date dateExtraction) {
    		this.dateExtraction = dateExtraction;
    	}
     
    	@OneToMany(fetch = FetchType.LAZY, mappedBy = "deci")
    	public Set<Patient> getPatients() {
    		return this.patients;
    	}
     
    	public void setPatients(Set<Patient> patients) {
    		this.patients = patients;
    	}
     
    }
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    package objets;
     
    // Generated 22 janv. 2015 11:41:05 by Hibernate Tools 4.0.0
     
    import java.math.BigDecimal;
    import java.util.Date;
    import java.util.HashSet;
    import java.util.Set;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import static javax.persistence.GenerationType.IDENTITY;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.JoinTable;
    import javax.persistence.ManyToMany;
    import javax.persistence.ManyToOne;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;
    import javax.persistence.Temporal;
    import javax.persistence.TemporalType;
     
    /**
     * Patient generated by hbm2java
     */
    @Entity
    @Table(name = "patient", catalog = "defib")
    public class Patient implements java.io.Serializable {
     
    	private Integer idPatient;
    	private Cardiopathie cardiopathieByIdCardiopathie2;
    	private Cardiopathie cardiopathieByIdCardiopathie;
    	private MotifImplantation motifImplantation;
    	private Personnel personnel;
    	private Deci deci;
    	private String nom;
    	private String prenom;
    	private boolean masculin;
    	private Date dateNaissance;
    	private Date dateDebutTc;
    	private BigDecimal fevg;
    	private boolean antecendentFibrilation;
    	private String typeFibrilation;
    	private boolean permanenteFibrilation;
    	private String commentaire;
    	private String statut;
    	private Date dateDeces;
    	private Date dateAjout;
    	private String coordonnees;
    	private Date dateEri;
    	private Date dateDemandeChangement;
    	private Date blocPrevue;
    	private String patientPrevenu;
    	private Set<Rdv> rdvs = new HashSet<Rdv>(0);
    	private Set<Action> actions = new HashSet<Action>(0);
    	private Set<Etude> etudes = new HashSet<Etude>(0);
    	private Set<Message> messages = new HashSet<Message>(0);
    	private Set<Deci> decis = new HashSet<Deci>(0);
     
    	public Patient() {
    	}
     
    	public Patient(String nom, String prenom, boolean masculin,
    			BigDecimal fevg, boolean antecendentFibrilation,
    			String typeFibrilation, boolean permanenteFibrilation,
    			String commentaire, String statut, String coordonnees) {
    		this.nom = nom;
    		this.prenom = prenom;
    		this.masculin = masculin;
    		this.fevg = fevg;
    		this.antecendentFibrilation = antecendentFibrilation;
    		this.typeFibrilation = typeFibrilation;
    		this.permanenteFibrilation = permanenteFibrilation;
    		this.commentaire = commentaire;
    		this.statut = statut;
    		this.coordonnees = coordonnees;
    	}
     
    	public Patient(Cardiopathie cardiopathieByIdCardiopathie2,
    			Cardiopathie cardiopathieByIdCardiopathie,
    			MotifImplantation motifImplantation, Personnel personnel,
    			Deci deci, String nom, String prenom, boolean masculin,
    			Date dateNaissance, Date dateDebutTc, BigDecimal fevg,
    			boolean antecendentFibrilation, String typeFibrilation,
    			boolean permanenteFibrilation, String commentaire, String statut,
    			Date dateDeces, Date dateAjout, String coordonnees, Date dateEri,
    			Date dateDemandeChangement, Date blocPrevue, String patientPrevenu,
    			Set<Rdv> rdvs, Set<Action> actions, Set<Etude> etudes,
    			Set<Message> messages, Set<Deci> decis) {
    		this.cardiopathieByIdCardiopathie2 = cardiopathieByIdCardiopathie2;
    		this.cardiopathieByIdCardiopathie = cardiopathieByIdCardiopathie;
    		this.motifImplantation = motifImplantation;
    		this.personnel = personnel;
    		this.deci = deci;
    		this.nom = nom;
    		this.prenom = prenom;
    		this.masculin = masculin;
    		this.dateNaissance = dateNaissance;
    		this.dateDebutTc = dateDebutTc;
    		this.fevg = fevg;
    		this.antecendentFibrilation = antecendentFibrilation;
    		this.typeFibrilation = typeFibrilation;
    		this.permanenteFibrilation = permanenteFibrilation;
    		this.commentaire = commentaire;
    		this.statut = statut;
    		this.dateDeces = dateDeces;
    		this.dateAjout = dateAjout;
    		this.coordonnees = coordonnees;
    		this.dateEri = dateEri;
    		this.dateDemandeChangement = dateDemandeChangement;
    		this.blocPrevue = blocPrevue;
    		this.patientPrevenu = patientPrevenu;
    		this.rdvs = rdvs;
    		this.actions = actions;
    		this.etudes = etudes;
    		this.messages = messages;
    		this.decis = decis;
    	}
     
    	@Id
    	@GeneratedValue(strategy = IDENTITY)
    	@Column(name = "id_patient", unique = true, nullable = false)
    	public Integer getIdPatient() {
    		return this.idPatient;
    	}
     
    	public void setIdPatient(Integer idPatient) {
    		this.idPatient = idPatient;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_cardiopathie2")
    	public Cardiopathie getCardiopathieByIdCardiopathie2() {
    		return this.cardiopathieByIdCardiopathie2;
    	}
     
    	public void setCardiopathieByIdCardiopathie2(
    			Cardiopathie cardiopathieByIdCardiopathie2) {
    		this.cardiopathieByIdCardiopathie2 = cardiopathieByIdCardiopathie2;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_cardiopathie")
    	public Cardiopathie getCardiopathieByIdCardiopathie() {
    		return this.cardiopathieByIdCardiopathie;
    	}
     
    	public void setCardiopathieByIdCardiopathie(
    			Cardiopathie cardiopathieByIdCardiopathie) {
    		this.cardiopathieByIdCardiopathie = cardiopathieByIdCardiopathie;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_motif_implantation")
    	public MotifImplantation getMotifImplantation() {
    		return this.motifImplantation;
    	}
     
    	public void setMotifImplantation(MotifImplantation motifImplantation) {
    		this.motifImplantation = motifImplantation;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_medecin_traitant")
    	public Personnel getPersonnel() {
    		return this.personnel;
    	}
     
    	public void setPersonnel(Personnel personnel) {
    		this.personnel = personnel;
    	}
     
    	@ManyToOne(fetch = FetchType.LAZY)
    	@JoinColumn(name = "id_futur_deci")
    	public Deci getDeci() {
    		return this.deci;
    	}
     
    	public void setDeci(Deci deci) {
    		this.deci = deci;
    	}
     
    	@Column(name = "nom", nullable = false)
    	public String getNom() {
    		return this.nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	@Column(name = "prenom", nullable = false)
    	public String getPrenom() {
    		return this.prenom;
    	}
     
    	public void setPrenom(String prenom) {
    		this.prenom = prenom;
    	}
     
    	@Column(name = "masculin", nullable = false)
    	public boolean isMasculin() {
    		return this.masculin;
    	}
     
    	public void setMasculin(boolean masculin) {
    		this.masculin = masculin;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_naissance", length = 0)
    	public Date getDateNaissance() {
    		return this.dateNaissance;
    	}
     
    	public void setDateNaissance(Date dateNaissance) {
    		this.dateNaissance = dateNaissance;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_debut_tc", length = 0)
    	public Date getDateDebutTc() {
    		return this.dateDebutTc;
    	}
     
    	public void setDateDebutTc(Date dateDebutTc) {
    		this.dateDebutTc = dateDebutTc;
    	}
     
    	@Column(name = "fevg", nullable = false, precision = 5)
    	public BigDecimal getFevg() {
    		return this.fevg;
    	}
     
    	public void setFevg(BigDecimal fevg) {
    		this.fevg = fevg;
    	}
     
    	@Column(name = "antecendent_fibrilation", nullable = false)
    	public boolean isAntecendentFibrilation() {
    		return this.antecendentFibrilation;
    	}
     
    	public void setAntecendentFibrilation(boolean antecendentFibrilation) {
    		this.antecendentFibrilation = antecendentFibrilation;
    	}
     
    	@Column(name = "type_fibrilation", nullable = false, length = 16)
    	public String getTypeFibrilation() {
    		return this.typeFibrilation;
    	}
     
    	public void setTypeFibrilation(String typeFibrilation) {
    		this.typeFibrilation = typeFibrilation;
    	}
     
    	@Column(name = "permanente_fibrilation", nullable = false)
    	public boolean isPermanenteFibrilation() {
    		return this.permanenteFibrilation;
    	}
     
    	public void setPermanenteFibrilation(boolean permanenteFibrilation) {
    		this.permanenteFibrilation = permanenteFibrilation;
    	}
     
    	@Column(name = "commentaire", nullable = false, length = 65535)
    	public String getCommentaire() {
    		return this.commentaire;
    	}
     
    	public void setCommentaire(String commentaire) {
    		this.commentaire = commentaire;
    	}
     
    	@Column(name = "statut", nullable = false, length = 30)
    	public String getStatut() {
    		return this.statut;
    	}
     
    	public void setStatut(String statut) {
    		this.statut = statut;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_deces", length = 0)
    	public Date getDateDeces() {
    		return this.dateDeces;
    	}
     
    	public void setDateDeces(Date dateDeces) {
    		this.dateDeces = dateDeces;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_ajout", length = 0)
    	public Date getDateAjout() {
    		return this.dateAjout;
    	}
     
    	public void setDateAjout(Date dateAjout) {
    		this.dateAjout = dateAjout;
    	}
     
    	@Column(name = "coordonnees", nullable = false)
    	public String getCoordonnees() {
    		return this.coordonnees;
    	}
     
    	public void setCoordonnees(String coordonnees) {
    		this.coordonnees = coordonnees;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_eri", length = 0)
    	public Date getDateEri() {
    		return this.dateEri;
    	}
     
    	public void setDateEri(Date dateEri) {
    		this.dateEri = dateEri;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "date_demande_changement", length = 0)
    	public Date getDateDemandeChangement() {
    		return this.dateDemandeChangement;
    	}
     
    	public void setDateDemandeChangement(Date dateDemandeChangement) {
    		this.dateDemandeChangement = dateDemandeChangement;
    	}
     
    	@Temporal(TemporalType.DATE)
    	@Column(name = "bloc_prevue", length = 0)
    	public Date getBlocPrevue() {
    		return this.blocPrevue;
    	}
     
    	public void setBlocPrevue(Date blocPrevue) {
    		this.blocPrevue = blocPrevue;
    	}
     
    	@Column(name = "patient_prevenu", length = 65535)
    	public String getPatientPrevenu() {
    		return this.patientPrevenu;
    	}
     
    	public void setPatientPrevenu(String patientPrevenu) {
    		this.patientPrevenu = patientPrevenu;
    	}
     
    	@OneToMany(fetch = FetchType.LAZY, mappedBy = "patient")
    	public Set<Rdv> getRdvs() {
    		return this.rdvs;
    	}
     
    	public void setRdvs(Set<Rdv> rdvs) {
    		this.rdvs = rdvs;
    	}
     
    	@OneToMany(fetch = FetchType.LAZY, mappedBy = "patient")
    	public Set<Action> getActions() {
    		return this.actions;
    	}
     
    	public void setActions(Set<Action> actions) {
    		this.actions = actions;
    	}
     
    	@ManyToMany(fetch = FetchType.LAZY)
    	@JoinTable(name = "patient_etude", catalog = "defib", joinColumns = { @JoinColumn(name = "id_patient", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "id_etude", nullable = false, updatable = false) })
    	public Set<Etude> getEtudes() {
    		return this.etudes;
    	}
     
    	public void setEtudes(Set<Etude> etudes) {
    		this.etudes = etudes;
    	}
     
    	@OneToMany(fetch = FetchType.LAZY, mappedBy = "patient")
    	public Set<Message> getMessages() {
    		return this.messages;
    	}
     
    	public void setMessages(Set<Message> messages) {
    		this.messages = messages;
    	}
     
    	@OneToMany(fetch = FetchType.LAZY, mappedBy = "patient")
    	public Set<Deci> getDecis() {
    		return this.decis;
    	}
     
    	public void setDecis(Set<Deci> decis) {
    		this.decis = decis;
    	}
     
    }
    J'ai de gros problèmes avec les jointures ou j'ai essayé avec 36 trucs (des inner join, des jointures implicite en mettant simplement une virgule, en variant la syntaxe de celle de sql à celle de Java, etc).

    J'ai un problème avec cette jointure :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Session session=HibernateUtil.currentSession();
    		Query query = session.createQuery("SELECT D FROM objets.Patient AS P , objets.Deci AS D WHERE D.idPatient=P.idPatient");
    J'ai l'erreur :
    could not resolve property: idPatient of: objets.Deci

    Et si je fait SELECT D FROM objets.Patient AS P , objets.Deci AS D WHERE D.id_patient=P.id_patient, j'ai
    could not resolve property: id_patient of: objets.Deci

    Mêmes problèmes en trifouillant avec des JOIN ou des INNER JOIN

  2. #2
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    peux-tu changer ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Query query = session.createQuery("SELECT D FROM objets.Patient AS P , objets.Deci AS D WHERE D.idPatient=P.idPatient");
    en
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
      Query query = session.createQuery("SELECT d FROM Patient p , Deci  d WHERE d.idPatient=p.idPatient");
    eric

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    676
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 676
    Points : 121
    Points
    121
    Par défaut
    OK je viens de tester ta requête en faisant un copier coller et j'ai toujours cette erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     could not resolve property: idPatient of: objets.Deci

  4. #4
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    une erreur de ma part:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Query query = session.createQuery("SELECT d FROM Patient p , Deci  d WHERE d.patient =p");

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    676
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 676
    Points : 121
    Points
    121
    Par défaut
    Super merci pour ton aide. Je n'y aurais pas pensé tout seul.
    Par contre j'ai un autre soucis. Je souhaite séléctionner tous les patients dont le modèle de Deci est celui d'id 17.

    Mais ni SELECT d FROM Patient p , Deci d WHERE d.patient =p AND d.idModeleDeci=17 ni SELECT d FROM Patient p , Deci d WHERE d.patient =p AND d.id_modele_deci=17 ne fonctionnent.
    J'ai à nouveau les erreurs :
    could not resolve property: idModeleDeci of: objets.Deciet
    could not resolve property: id_modele_deci of: objets.Deci
    C'est dingue qu'on ne puisse pas accéder comme ça aux propriétés, quand on ne fait pas de jointure c'est possible.

  6. #6
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut
    peux-tu nous montrer la classe ModeleDeci.java

    Eric

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    676
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2006
    Messages : 676
    Points : 121
    Points
    121
    Par défaut
    C'est bon je crois avoir compris le truc, je fais cette requête :
    SELECT d FROM Patient p , Deci d WHERE d.patient =p AND d.modeleDeci.id=17
    Et ça marche. Merci pour ton aide qui m'a été très précieuse. C'est bizarre mais dans les docs officielles de Hibernate c'est pas très clair ce truc.

  8. #8
    Rédacteur/Modérateur
    Avatar de Logan Mauzaize
    Homme Profil pro
    Architecte technique
    Inscrit en
    Août 2005
    Messages
    2 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : Transports

    Informations forums :
    Inscription : Août 2005
    Messages : 2 894
    Points : 7 083
    Points
    7 083
    Par défaut
    Citation Envoyé par Ceubex Voir le message
    Et ça marche. Merci pour ton aide qui m'a été très précieuse. C'est bizarre mais dans les docs officielles de Hibernate c'est pas très clair ce truc.
    La documentation est très clair, HQL (et Hibernate de manière général) ne travaille qu'avec des "propriétés" de ton mapping.
    Ainsi l'entité "Deci" n'a ni propriété "idPatient", ni "id_modele_deci". Tu dois penser comme en objet et plus en relationnel.
    Java : Cours et tutoriels - FAQ - Java SE 8 API - Programmation concurrente
    Ceylon : Installation - Concepts de base - Typage - Appels et arguments

    ECM = Exemple(reproduit le problème) Complet (code compilable) Minimal (ne postez pas votre application !)
    Une solution vous convient ? N'oubliez pas le tag
    Signature par pitipoisson

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 28/12/2010, 11h08
  2. [Liferay] exception: org.hibernate.QueryException: could not resolve property
    Par lamis2009 dans le forum Portails
    Réponses: 2
    Dernier message: 11/06/2010, 11h13
  3. hibernate.QueryException: could not resolve property
    Par g56589 dans le forum Hibernate
    Réponses: 2
    Dernier message: 29/01/2008, 23h45
  4. [Hibernate] "could not resolve property" sur un tri
    Par Gorou dans le forum Hibernate
    Réponses: 1
    Dernier message: 13/07/2007, 12h27
  5. could not resolve property
    Par *alexandre* dans le forum Hibernate
    Réponses: 1
    Dernier message: 30/10/2006, 13h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo