개체 내에 개체가 있고 가장 안쪽 개체 내의 필드 중 하나를 사용하여 제한을 만들고 싶습니다. 이제 다음과 같은 작업을 수행하여 얻을 수 있다고 생각했습니다.
... .add (Restrictions.eq ( "myObjectTwp.myObjectThree.myObjectsID", mySearchId)). list ();
그러나 이것은 작동하지 않는 것 같습니다. 그러나 오류 메시지가 나타나지 않고 대신 이러한 제한이 고려되지 않은 것처럼 보입니다.
가입해야합니다. 기준 API에서이를 수행하는 가장 쉬운 방법은 createAlias () 메소드를 사용하는 것입니다.
session.createCriteria(Child.class, "child")
.createAlias("child.parent", "theParent")
.add(Restrictions.eq("theParent.someField", theFieldValue))
.list();
이 쿼리는 다음 HQL과 동일합니다.
select child from Child child
inner join child.parent theParent
where theParent.someField = :theFieldValue
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다