-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria Query + component
PostPosted: Thu Nov 05, 2009 7:40 am 
Newbie

Joined: Thu Nov 05, 2009 7:10 am
Posts: 1
Hi All,
I'm getting following error, when i try to retrieve a component object, please help me to solve this,

org.springframework.orm.hibernate3.HibernateQueryException: property does not map to a single column: audit; nested exception is org.hibernate.QueryException: property does not map to a single column: audit

following is my java method:
Code:
public List<Ad> retrieveAdListByUserProfileId(PagingParameter pagingParameter, SortConstraint sortConstraint,
            List<String> status, UserType userType, long userProfileId) {

        DetachedCriteria criteria = DetachedCriteria.forClass(Ad.class);
        ProjectionList projectionList = Projections.projectionList();
        projectionList.add(Projections.id().as("id"));
        projectionList.add(Projections.property("adName").as("adName"));
        projectionList.add(Projections.property("adTypeStr").as("adTypeStr"));
        projectionList.add(Projections.property("startDate").as("startDate"));
        projectionList.add(Projections.property("endDate").as("endDate"));
        projectionList.add(Projections.property("noOfPrints").as("noOfPrints"));
        projectionList.add(Projections.property("workflowStatusStr").as("workflowStatusStr"));
        projectionList.add(Projections.property("printRecordsPresent").as("printRecordsPresent"));
        projectionList.add(Projections.property("actionRecordsPresent").as("actionRecordsPresent"));
        projectionList.add(Projections.property("audit").as("audit"));

        // This specifies the class which is used to hold the retuned data.
        criteria.setProjection(projectionList).setResultTransformer(new AliasToBeanResultTransformer(Ad.class));

        if (status != null) {
            criteria.add(Restrictions.in("this.workflowStatusStr", status));
        }
        if (UserType.RETAILER.getRole().equals(userType.getRole())) {
            criteria = criteria.createAlias("this.program", "program");
            criteria = criteria.createAlias("this.program.retailerProfile", "retailerProfile");
            criteria.add(Restrictions.eq("retailerProfile.id", userProfileId));
        } else {
            criteria = criteria.createAlias("this.program", "program");
            criteria = criteria.createAlias("this.program.advertiserProfile", "advertiserProfile");
            criteria.add(Restrictions.eq("advertiserProfile.id", userProfileId));
        }

        if (sortConstraint != null) {
            if (sortConstraint.isOrderAscending())
                criteria.addOrder(Order.asc("this." + sortConstraint.getPropertyName()));
            else
                criteria.addOrder(Order.desc("this." + sortConstraint.getPropertyName()));
        }

        if (pagingParameter == null) {
            return getHibernateTemplate().findByCriteria(criteria);
        } else {
            return getHibernateTemplate().findByCriteria(criteria, pagingParameter.getStartIndex(),
                    pagingParameter.getNoOfRecords());
        }

    }




Following is my hibernate mapping document
Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
   <!-- Generated Jun 20, 2009 11:29:44 PM by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
   <class name="com.instream.ams.domain.Ad" table="ad">
      <id name="id" type="long">
         <column name="id" />
         <generator class="identity" />
      </id>
      <many-to-one name="program" class="com.instream.ams.domain.Program"
         fetch="select">
         <column name="program_id" not-null="true" />
      </many-to-one>
      <property name="adName" type="string">
         <column name="ad_name" length="45" not-null="true" />
      </property>
      <property name="adTypeStr" column="ad_type" type="string"
         access="field">
      </property>
      <property name="noOfPrints" type="java.lang.Long">
         <column name="no_of_prints" />
      </property>
      <property name="cpmAmount" type="double">
         <column name="cpm_amount" precision="12" scale="2" />
      </property>
      <property name="cpaAmount" type="double">
         <column name="cpa_amount" precision="12" scale="2" />
      </property>
      <property name="startDate" type="timestamp">
         <column name="start_date" length="19" />
      </property>
      <property name="endDate" type="timestamp">
         <column name="end_date" length="19" />
      </property>
      <property name="workflowStatusStr" column="workflow_status"
         type="string" access="field">
      </property>
      <property name="priority" type="string">
         <column name="priority" length="20" />
      </property>
      <property name="advertiserCodeEnabled" type="java.lang.Boolean">
         <column name="advertiser_code_enabled" />
      </property>
      <property name="couponId" type="string">
         <column name="coupon_id" length="45" />
      </property>
      <property name="exportedDate" type="timestamp">
         <column name="exported_date" length="19" />
      </property>      
      <property name="retailerAdId" type="string">
         <column name="retailer_ad_id" length="250"/>
      </property>
      <property name="printRecordsPresent" type="java.lang.Boolean">
         <column name="printrecords_present" />
      </property>
      <property name="actionRecordsPresent" type="java.lang.Boolean">
         <column name="actionrecords_present" />
      </property>
      <component name="adContent" class="com.instream.ams.domain.AdContent" >
         <property name="adImage" type="string">
            <column name="ad_image" length="120" />
         </property>
         <property name="adText" type="string">
            <column name="ad_text" length="65535" />
         </property>
         <property name="barcode" type="string">
            <column name="barcode" length="45" />
         </property>
         <property name="barcodeType" type="string">
            <column name="barcode_type" length="20" />
         </property>
            <property name="adImageSize" type="long">
            <column name="ad_image_size" />
         </property>
         <property name="adImageName" type="string">
            <column name="ad_image_name" length="255" />
         </property>
        </component>
      <component name="audit" class="com.instream.ams.domain.Audit">
         <property name="createdDate" type="timestamp">
            <column name="created_date" length="19" />
         </property>
         <property name="modifiedDate" type="timestamp">
            <column name="modified_date" length="19" />
         </property>
         <property name="cancelledDate" type="timestamp">
            <column name="cancelled_date" length="19" />
         </property>
         <property name="ownerUserUri" type="string">
            <column name="owner_user_uri" length="150" not-null="true" />
         </property>
         <property name="modifiedUserUri" type="string">
            <column name="modified_user_uri" length="150" />
         </property>
      </component>
      <!--
         set name="adContents" inverse="true" lazy="true" table="ad_content"
         fetch="select"> <key> <column name="ad_id" not-null="true" /> </key>
         <one-to-many class="com.instream.ams.domain.AdContent" /> </set
      -->
      <!--
         set name="adProgramStoreLocations" inverse="true" lazy="true"
         table="ad_program_store_location" fetch="select"> <key> <column
         name="ad_id" not-null="true" /> </key> <one-to-many
         class="com.instream.ams.domain.AdProgramStoreLocation" /> </set
      -->
      <set name="retailerStoreLocations" table="ad_program_store_location"
         cascade="save-update" lazy="true">
         <key>
            <column name="ad_id" />
         </key>
         <many-to-many class="com.instream.ams.domain.RetailerStoreLocation"
            column="store_location_id" unique="true" />
      </set>
      <set name="productCategories" table="ad_program_product_category"
         cascade="save-update" lazy="true">
         <key>
            <column name="ad_id" />
         </key>
         <many-to-many class="com.instream.ams.domain.ProductCategory"
            column="product_category_id" unique="true" />
      </set>
   </class>
</hibernate-mapping>


Thanks
Sam.


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

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.