-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Creating aliases causes the search to loose some objects
PostPosted: Fri Apr 28, 2006 12:25 pm 
Newbie

Joined: Fri Mar 03, 2006 5:55 am
Posts: 7
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 3:16 am 
Beginner
Beginner

Joined: Fri Jul 29, 2005 10:34 am
Posts: 25
hi,

We had the same problem and my conclusion was: "when using ICriteria" to create alias your join type get's lost (fixed to inner join) deriving to different results.

And when debugging the NHibernate code i think i found the reason.

Please look at this thread: http://forum.hibernate.org/viewtopic.php?t=958858


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.