Si, c'est possible, il faut que tu créés un objet wrapper qui contient les champs que tu souhaites récupérer:
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
| /*
* Resultat.java
*
* Created on 6 juin 2007, 09:47
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author Propriétaire
*/
public class Resultat {
private int id_region;
private String libelle_region;
private String lib_zone;
/**
* Creates a new instance of Resultat
*/
public Resultat(int id_region, String libelle_region, String lib_zone) {
this.id_region = id_region;
this.libelle_region = libelle_region;
this.lib_zone = lib_zone;
}
public int getId_region() {
return id_region;
}
public void setId_region(int id_region) {
this.id_region = id_region;
}
public String getLibelle_region() {
return libelle_region;
}
public void setLibelle_region(String libelle_region) {
this.libelle_region = libelle_region;
}
public String getLib_zone() {
return lib_zone;
}
public void setLib_zone(String lib_zone) {
this.lib_zone = lib_zone;
}
} |
Ensuite tu créés ta requête EJB-QL comme suit:
SELECT new javaapplication1.Resultat(r.id_region, r.libelle_region, z.lib_zone) FROM Region r, Zone z WHERE r.id_zone=z.id_zone
(ou quelque chose comme ça, je n'ai pas mes exemples sous la main).
Valère
Partager