2010-10-11 5 views
0

salut suis nouveau et hiberner me rend fou à plein temps. i hv 2 tables mappage un-2-one. quand je rejoins seulement ces 2 ces deux là alors hibernate n'est pas mappage et quand je rejoins table1 avec un autre table3 alors il me donne de bons résultats mappés.hibernate ne mappant pas le bean, retournant la liste d'objets

Bean1

private int id ; 
private BlessUser blessUser ; 
private SnsAuthenticator snsAuth ; 
public void setSnsAuth(SnsAuthenticator snsAuth) { 
    snsAuth.setSnsUserId(getId()); 
    this.snsAuth = snsAuth; 
} 

fichier HBM

<one-to-one name="snsAuth" class="com.utilami.model.SnsAuthenticator" property-ref="snsUserId" 
    cascade="all"></one-to-one> 

Bean2

private int id; 
private int snsUserId; 
private String key; 
private String value; 

fichier HBM hbm normal ...

exécution lik:

Session session = Utility.getSessionFactory().openSession(); 
    Query query = session.createQuery("from SnsUser su join su.snsAuth sa where su.blessUserId =1"); 
    List list = query.list(); 

Cette requête fonctionne très bien

String query = "from BlessUser bu join fetch bu.snsUser su where bu.id = su.blessUserId and bu." + "UserName" + " = " + "'qw'"; 

un grand merci à l'avance. thx

Répondre

0
from SnsUser su join fetch su.snsAuth sa where su.blessUserId = :id

Le mot-clé fetch était manquante.

Questions connexes