Problème annotation Hibernate
Bonjour;
je développe une application web (JSF+primefaces+Hibernate+Oracle11g)
j'ai trois tables: Fonctionnalite, Profile et ProfileFonctionnalite.
elles sont mappées de la façon suivate:
Fonctionnalite
Code:
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
| package winservices.mapping;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Proxy;
@Entity
@Table(name="TBL_FONCTIONALITE")
public class Fonctionnalite implements Serializable{
private static final long serialVersionUID = 1L;
private String codeFonctionalite;
private String fonctionalite;
private Fonctionnalite parent;
private String lien;
private String methode;
private String statut;
private String module;
private int ordre;
@Id
@Column (name="code_fonctionalite")
public String getCodeFonctionalite() {
return codeFonctionalite;
}
public void setCodeFonctionalite(String codeFonctionalite) {
this.codeFonctionalite = codeFonctionalite;
}
@Column (name="fonctionalite")
public String getFonctionalite() {
return fonctionalite;
}
public void setFonctionalite(String fonctionalite) {
this.fonctionalite = fonctionalite;
}
@Column (name="lien")
public String getLien() {
return lien;
}
public void setLien(String lien) {
this.lien = lien;
}
@Column (name="methode")
public String getMethode() {
return methode;
}
public void setMethode(String methode) {
this.methode = methode;
}
@Column (name="ordre")
public int getOrdre() {
return ordre;
}
public void setOrdre(int ordre) {
this.ordre = ordre;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn (name="ref_parent")
public Fonctionnalite getParent() {
return parent;
}
public void setParent(Fonctionnalite parent) {
this.parent = parent;
}
@Column (name="statut")
public String getStatut() {
return statut;
}
public void setStatut(String statut) {
this.statut = statut;
}
@Column (name="module")
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
} |
Profile
Code:
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
| package winservices.mapping;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Proxy;
@Entity
@Table(name="TBL_PROFILE")
public class Profile implements Serializable{
private static final long serialVersionUID = 1L;
private String codeProfile;
private String profile;
@Id
@Column (name="code_profile")
public String getCodeProfile() {
return codeProfile;
}
public void setCodeProfile(String codeProfile) {
this.codeProfile = codeProfile;
}
@Column (name="profile")
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
} |
ProfileFonctionnalte
Code:
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
| package winservices.mapping;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Proxy;
@Entity
@Table(name="TBL_PROFILE_FONCTIONALITE")
public class ProfileFonctionalite implements Serializable{
private static final long serialVersionUID = 1L;
private Long id;
private Profile profile;
private Fonctionnalite fonctionalite;
@Id
@Column (name="id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn (name="code_profile")
public Profile getProfile() {
return profile;
}
public void setProfile(Profile profile) {
this.profile = profile;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn (name="code_fonctionalite")
public Fonctionnalite getFonctionalite() {
return fonctionalite;
}
public void setFonctionalite(Fonctionnalite fonctionalite) {
this.fonctionalite = fonctionalite;
}
} |
Dans la classe DAO, je fais une requete qui retourne une liste d'objet ProfileFonctionnalite (chose faite) dont chaque objet ProfileFonctionnalite pointe sur une liste d'objet Fonctionnalite
mais quand je debuggue je trouve les objets Foctionnalite ne sont pas renseignés.
Est ce quelqu'un peut me donner un coup de main?
La requete:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| @SuppressWarnings("unchecked")
public List<ProfileFonctionalite> getListFonctionalitesParProfil( Profile profile) throws Exception
{
List <ProfileFonctionalite> listProfilesFonctionalites=null;
Session session = SessionFactoryUtil.getSessionFactory().openSession();
try
{
String queryString = "from ProfileFonctionalite pf where pf.profile= :profile order by pf.fonctionalite.ordre ";
Query query = session.createQuery(queryString);
query.setParameter("profile", profile);
listProfilesFonctionalites = query.list();
}
catch (Exception e)
{
throw e;
}
return listProfilesFonctionalites;
} |
Merci d'avance