Hi guys, I'm running into a criteria issue. Maybe you can shine some light for me? :)
I will attach the mapping files of two domain objs. Activity and UploadedClaim. On UploadedClaim, Activity is mapped as a one-to-one relationship.
Because the UploadedClaim has two blob fields, querying those fields really slow down the performance. I'm trying to avoid selecting those fields during a search. So I tried using Projections.
Hibernate version: 3.2.2
Name and version of the database you are using: Oracle 10g
Mapping documents:
Activity:
Code:
<class name="com.rainhail.claim.eadjuster.core.domain.Activity"
table="common.activity" >
<id name="activityId" column="activity_id" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">common.activity_seq</param>
</generator>
</id>
<many-to-one name="activityType" column="activity_type_id"
not-null="true" />
<property name="activityDate" column="activity_date"
type="java.util.Date" not-null="true" />
<property name="division" column="division"
type="java.lang.Integer" not-null="true" />
<property name="policySymbol" column="policy_symbol"
type="string" not-null="true" />
<property name="policyNumber" column="policy_number"
type="java.lang.Integer" not-null="true" />
<property name="claimNumber" column="claim_number"
type="java.lang.Integer" not-null="true" />
<property name="webUserProfileId" column="id"
type="java.lang.Integer" not-null="true" />
</class>
UploadedClaim:
Code:
<class name="com.rainhail.claim.eadjuster.core.domain.UploadedClaim"
table="common.upload_claim">
<id name="uploadedClaimId" column="activity_id" type="java.lang.Long">
<generator class="foreign">
<param name="property">activity</param>
</generator>
</id>
<one-to-one name="activity" constrained="true" lazy="false" />
<many-to-one name="uploadStatus" column="status_id" not-null="true" />
<property name="document" column="document"
type="com.rainhail.claim.eadjuster.core.dao.hibernate.BlobUserType"
not-null="false" length="4000000" />
<property name="xmlDocument" column="document_xml"
type="com.rainhail.claim.eadjuster.core.dao.hibernate.BlobUserType"
not-null="false" length="4000000" />
<property name="processedDate" column="processed_date"
type="java.util.Date" />
<property name="processedBy" column="processed_by" type="string" />
</class>
Code between sessionFactory.openSession() and session.close():Code:
Criteria pageC = session.createCriteria(UploadedClaim.class);
ProjectionList projList = Projections.projectionList();
projList.add(Projections.property("uploadedClaimId"));
projList.add(Projections.property("activity"));
projList.add(Projections.property("uploadStatus"));
pageC.setProjection(projList);
Then pageC.list() returns a list of Object Array but the second parameter in the object array for activity is always null even though they exist in the db. I know it probably has something to do with the mapping.
I don't know if there is a way around this? I really do not want to abandon using Criteria since we have to perform search based on the uploadStatus and will need the properties on the activity obj to populate the search results.
Thanks