hi am new and hibernate is driving me crazy full time. i hv 2 tables one-2-one mapping. when i join only these 2 these two then hibernate is not mapping and when i join table1 with some other table3 then its giving me fine mapped results.
Bean1
private int id ;
private BlessUser blessUser ;
private SnsAuthenticator snsAuth ;
public void setSnsAuth(SnsAuthenticator snsAuth) {
snsAuth.setSnsUserId(getId());
this.snsAuth = snsAuth;
}
HBM file
<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;
HBM file normal hbm...
Executing 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();
This query works fine
String query = "from BlessUser bu join fetch bu.snsUser su where bu.id = su.blessUserId and bu." + "UserName" + " = " + "'qw'";
many thanks in advance. thx
from SnsUser su join fetch su.snsAuth sa where su.blessUserId = :id
The fetch
keyword was missing.
精彩评论