2011-02-04 3 views
1

기본 클래스를 조회 할 때 NHibernate는 각 기본 서브 클래스에 대해 왼쪽 외부 조인을 작성합니다. 이는 쿼리가 기본의 속성에만 있고 투영이 해당 속성에 설정된 경우에도 발생합니다.nhibernate가 서브 클래스에 대해 왼쪽 외부 조인을 작성하지 못하게하는 방법

예 :

SELECT this_.Id as y0_, this_.Name as y1_ FROM AnimalBase this_ 
    left outer join Dog this_1_ on this_.Id=this_1_.AnimalBaseFK 
    left outer join Cat this_2_ on this_.Id=this_2_.AnimalBaseFK 
WHERE lower(this_.Name) like @p0;@p0 = '%rover%' 

나는이 기본 동작을 변경하는 방법을 내 질문은?

감사

편집 : 여기

봐 :

NHibernate에 기본적으로 다형성 쿼리를 사용하기 때문에이 작업이 완료 How to perform a non-polymorphic HQL query in Hibernate?

답변

1

. 이렇게하면 내 말은 :

select * from Animal 

NHibernate에 모든 동물을 검색하려고합니다. 따라서 Animal을 상속하는 Dog 클래스를 사용하면 Dog가 Animal임을 의미합니다. (상속은 IS-A 관계를 설명하므로 논리입니다.)

이 동작을 해제 할 수 있습니다. 자세한 내용은 Loading a base class through nhibernate incorrectly uses mappings from derived classes

+0

Frederik에게 감사드립니다. 귀하가 주신 링크로 더 나은 사이트로 연결됩니다. http://stackoverflow.com/questions/2093025/how-to-perform-a-non-polymorphic-hql-query-in-hibernate/2094321#2094321 –

관련 문제