Hibernate version:
Mapping documents:
<class name="Common.Patients.Patient, Common" table="CLN_PATIENT">
<id name="Oid" column="ID">
<generator class="native">
<param name="sequence">CLN_PATIENT_SEQUENCE</param>
</generator>
</id>
<property name="FirstName" column="FIRST_NAME" type="Nullables.NHibernate.EmptyStringType, Nullables.Nhibernate" length="50"/>
<property name="SecondName" column="SECOND_NAME" type="Nullables.NHibernate.EmptyStringType, Nullables.Nhibernate" length="50"/>
<property name="LastName" column="LAST_NAME" type="Nullables.NHibernate.EmptyStringType, Nullables.Nhibernate" length="50"/>
<property name="Birthday" column="BIRTHDAY" type="Date"/>
</class>
<class name="Common.Patients.PatientDetail, Common" table="CLN_PATIENT" polymorphism="explicit">
<id name="Oid" column="ID">
<generator class="native">
<param name="sequence">CLN_PATIENT_SEQUENCE</param>
</generator>
</id>
<property name="FirstName" column="FIRST_NAME" type="Nullables.NHibernate.EmptyStringType, Nullables.Nhibernate" length="50"/>
<property name="SecondName" column="SECOND_NAME" type="Nullables.NHibernate.EmptyStringType, Nullables.Nhibernate" length="50"/>
<property name="LastName" column="LAST_NAME" type="Nullables.NHibernate.EmptyStringType, Nullables.Nhibernate" length="50"/>
<property name="Birthday" column="BIRTHDAY" type="Date"/>
<!-- ... Some other fields can go here -->
<!-- PatientDetail properties -->
<many-to-one cascade="all" name="Document" column="DOCUMENT" class="Common.Patients.PatientsDocument, Common"/>
<!-- ... Some other fields can go here -->
</class>
<class name="Common.Patients.PatientsDocument, Common" table="CLN_PATIENT_DOCUMENT">
<id name="Oid" column="ID">
<generator class="native">
<param name="sequence">CLN_PATIENT_DOC_SEQUENCE</param>
</generator>
</id>
<!-- Document Properties -->
<many-to-one name="DocumentType" column="DOCUMENT_TYPE" class="Common.Documents.Dictionaries.DocumentType, Common"/>
<property name="ValidUntil" column="VALID_UNTIL" type="Date"/>
<!-- PatientDocument Properties -->
<one-to-one name="Patient" property-ref="Document" class="Common.Patients.PatientDetail, Common"/>
</class>
<class name="Common.Documents.Dictionaries.DocumentType, Common" table="DOC_DOCUMENT_TYPE" >
<!-- DataTransferObject properties -->
<id name="Oid" column="ID" unsaved-value="0">
<generator class="native">
<param name="sequence">DOC_DOCUMENT_TYPE_SEQUENCE</param>
</generator>
</id>
<!-- DictionaryDataTransferObject properties -->
<property name="Name" column="NAME" length="50" unique="true"/>
<property name="Description" column="DESCRIPTION" type="Nullables.NHibernate.EmptyStringType, Nullables.NHibernate" length="255"/>
</class>
Code between sessionFactory.openSession() and session.close():
ICriteria criteria = Session.CreateCriteria(typeof(PatientDetail));
criteria.CreateAlias("Document", "D").CreateAlias("D.DocumentType", "DD");
IList list = criteria.List();
ICriteria criteria = Session.CreateCriteria(typeof(Patient));
IList list = criteria.List();
Full stack trace of any exception that occurs:
No exception occurs.
Name and version of the database you are using:
MSSQL 2000, and Oracle 9.2 (tested what described next only on mssql)
The database has both objects - that have document and those that have not. So when perfoming such kind of search in first case we receive only those that have a document, in the second type - all.
I wonder - why creating aliases influences the results of search, even when those aliases were not used in any criteria. Should it be so?
You may ask - why i do create alias and don't use it - well there is a situation where i should write 1 time create alias, and then perform 10 checks and create a criteria if any of them is true, or i should write 10 times create alias, 1 in every check.
Any help is welcome.
|