-->
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 problem
PostPosted: Thu Sep 29, 2011 7:51 am 
Newbie

Joined: Tue Sep 27, 2011 4:11 am
Posts: 14
Hey all,
I have a criteria which joins two tables : ProductInformation and Inventory with productId in both the tables and defined as primary key in ProductInformation table. I also defined a productid as foreign key in inventory also and then created this criteria:

Code:


   
   
   
    Criteria inv  = (Criteria) session.createCriteria(Inventory.class).createCriteria("productID").add(Restrictions.eq("productID",new Integer(1)));
   
    //ArrayList<Inventory> add = (ArrayList<Inventory>) inven.add(Restrictions.eq("ProductId", textField));
    list =  inv.list();
    System.out.println("Records"+list);
   
    session.close();






But it gives me this error:
org.hibernate.QueryException: not an association: productID

What is wrong with this criteria????


for reference here are the .xml files:
Code:
<hibernate-mapping>
    <class name="tpos.Inventory" table="INVENTORY">
        <id name="productID" type="java.lang.Integer">
            <column name="PRODUCTID" />
            <generator class="assigned" />
        </id>
        <property name="allocatedLocation" type="java.lang.String">
            <column name="ALLOCATEDLOCATION" />
        </property>
        <property name="allocationId" type="java.lang.Integer">
            <column name="ALLOCATIONID" />
        </property>
        <property name="sellable_Notsellable" type="java.lang.String">
            <column name="SELLABLE_NOTSELLABLE" />
        </property>
        <property name="sellablefromDate" type="java.util.Date">
            <column name="SELLABLEFROMDATE" />
        </property>
        <property name="sellableTill" type="java.util.Date">
            <column name="SELLABLETILL" />
        </property>
        <property name="shelfLocation" type="java.lang.Integer">
            <column name="SHELFLOCATION" />
        </property>
        <property name="quantitY" type="java.lang.Integer">
            <column name="QUANTITY" />
        </property>
        <property name="receivedQuantity" type="java.lang.Integer">
            <column name="RECEIVEDQUANTITY" />
        </property>
        <property name="soldQuantity" type="java.lang.Integer">
            <column name="SOLDQUANTITY" />
        </property>
        <property name="inhandQuantity" type="java.lang.Integer">
            <column name="INHANDQUANTITY" />
        </property>
        <property name="costtotalPrice" type="java.lang.Integer">
            <column name="COSTTOTALPRICE" />
        </property>
        <property name="saleunitPrice" type="java.lang.Integer">
            <column name="SALEUNITPRICE" />
        </property>
        <property name="notsellableReasoncode" type="java.lang.Integer">
            <column name="NOTSELLABLEREASONCODE" />
        </property>
        <property name="inventoryBarcode" type="java.lang.Integer">
            <column name="INVENTORYBARCODE" />
        </property>
    </class>
</hibernate-mapping>



Code:
<hibernate-mapping>
    <class name="tpos.ProductInformation" table="PRODUCTINFORMATION">
        <id name="productId" type="java.lang.Integer">
            <column name="PRODUCTID" />
            <generator class="assigned" />
        </id>
        <property name="productCode" type="java.lang.Integer">
            <column name="PRODUCTCODE" />
        </property>
        <property name="productName" type="java.lang.String">
            <column name="PRODUCTNAME" />
        </property>
        <property name="createdDate" type="java.util.Date">
            <column name="CREATEDDATE" />
        </property>
        <property name="expiryDate" type="java.util.Date">
            <column name="EXPIRYDATE" />
        </property>
        <property name="statuS" type="java.lang.String">
            <column name="STATUS" />
        </property>
        <property name="sellablE" type="java.lang.String">
            <column name="SELLABLE" />
        </property>
        <property name="purchaseDate" type="java.util.Date">
            <column name="PURCHASEDATE" />
        </property>
        <property name="barcodeNo" type="java.lang.Integer">
            <column name="BARCODENO" />
        </property>
        <property name="updationDate" type="java.util.Date">
            <column name="UPDATIONDATE" />
        </property>
        <property name="createdBy" type="java.lang.String">
            <column name="CREATEDBY" />
        </property>
        <property name="updatedBy" type="java.lang.String">
            <column name="UPDATEDBY" />
        </property>
        <property name="productCompType" type="java.lang.String">
            <column name="PRODUCTCOMPTYPE" />
        </property>
    </class>
</hibernate-mapping>



I basically need to show the productname from productinformation , productid from inventory so how will i get the productname from productinformation table????


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.