Bonjour,
J'ai un petit soucis avec une requête hibernante ,je ne comprends pas pourquoi ,cette requéte est sencé m'afficher des informations sur ce que j'appelle un mmdcontact suivant son prenom alors le resultat me l'affiche ainsi que d'autre mmdcontacs du meme pays !
J'ai fait pas mal de requéte avec d'autres attributs tous marche bien sauf que dans cette requéte je suis obligée d'utiliser inner join ,je crois que c'est ce qui me pose probléme !
Quelqu'un a une idée ? pourquoi cette requéte me retourne pas le resultat exacte ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Query req = getEntityManager().createQuery("SELECT ob2 FROM Location as ob2 inner join " + "ob2.lstLinkMmdLoc as listeLoc WHERE (lower(listeLoc.mmdContacts.mc_namefir) LIKE lower ('"+ cndmp +"%'))");
voici mon mapping :
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 public class MmdContacts { @Id private String mmd_c; private String email; private String mc_namefir; private String mc_namelas; @OneToMany(targetEntity = LinkMmdLoc.class, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @JoinColumn(name = "mmd_c") private Set<LinkMmdLoc> lstLinkMmdLoc; @ManyToOne(targetEntity = MmdRole.class) @JoinColumn(name = "role_c") private MmdRole role;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 public class LinkMmdLoc { @Id private String zgm25; @Id private String mmd_c; @ManyToOne(targetEntity = MmdContacts.class) @JoinColumn(name = "mmd_c", insertable = false , updatable = false) private MmdContacts mmdContacts; @ManyToOne(targetEntity = Location.class) @JoinColumn(name = "zgm25", insertable = false , updatable = false) private Location location;J'ai zappé les guetters et les setters !
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 public class Location { @Id private String zgm25; private String activ; @OneToMany(targetEntity = LinkMmdLoc.class, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @JoinColumn(name = "zgm25") private Set<LinkMmdLoc> lstLinkMmdLoc; @ManyToOne(targetEntity = ZgiDivision.class) @JoinColumn(name = "zdivision_c") private ZgiDivision division; @ManyToOne(targetEntity = ZgiSubregion.class) @JoinColumn(name = "zsubregion_c") private ZgiSubregion subregion;
Merci !
Partager