2017-02-27 12 views
0

이 문제가 있습니다. 그러나 어떤 일이 발생하는지 잘 모릅니다. 쿼리에 오류가 있습니까? 다른 검색어를 반환하는 이유는 무엇입니까?Criteria와 HQL이 동일한 쿼리를 구성하지 않습니다

기준 : 스레드에서

Query query = session.createQuery("FROM InventoryLocationAsset"); 
result = query.list(); 

예외 "주요"org.hibernate.ObjectNotFoundException :하지만, 중복 된 결과

HQL과

Criteria cr = session.createCriteria(InventoryLocationAsset.class); 
result = cr.list(); 

작품 미세 주어진 아니오 행 식별자가 존재 함


기준 :

Criteria cr = session.createCriteria(InventoryLocationAsset.class); 
cr.fetchMode("asset", FetchMode.JOIN); 
result = cr.list(); 

이 중복 된 결과

HQL으로 잘 작동하지만 :

Query query = session.createQuery("FROM InventoryLocationAsset _ILA JOIN FETCH _ILA.asset"); 
result = query.list(); 

작품 잘!

답변

0

귀하의 오류가 첫 번째 HQL 쿼리에 (중복 요소없이) :

Query query = session.createQuery("FROM InventoryLocationAsset"); 
result = query.list(); 

이 될 것입니다 :이 방법으로

Query query = session.createQuery("FROM " + InventoryLocationAsset.class.getName()); 
result = query.list(); 

당신은 당신의 클래스의 모든 경로를 넣어 것입니다. 중복 된 행에 대한

:

귀하의 InventoryLocationAsset 다른 기본 클래스입니까? 예인 경우 polimorphism 속성이 설정되어 있는지 확인하십시오 (explicit이어야 함).