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: Accessing parent table data
PostPosted: Sun Oct 26, 2008 11:19 pm 
Newbie

Joined: Wed Aug 01, 2007 4:00 am
Posts: 8
Dear Friends,

I have 2 pojos and its mapping files as follows:

public class OutsourcedProduct
{
private Long id;
private Vendor toBeRepairedBy;
private Set outsourcedProductReceiptList = new HashSet();
......
......
getters and setters
}

public class OutsourcedProductReceipt
{
private Long id;
private OutsourcedProduct parentId;
......
......
getters and setters
}

<hibernate-mapping>
<class name="my.app.OutsourcedProduct"
table="outsourced_product">
<id name="id" column="id">
<generator class="native" />
</id>
<many-to-one name="toBeRepairedBy" class="my.app.Vendor" column="toBeRepairedBy" not-null="true" />
<many-to-one name="parentId" class="my.app.ServiceEntry" column="parentId" not-null="true" />
<set name="outsourcedProductReceiptList" inverse="true" lazy="true" table="outsourced_product_receipt">
<key column="parentId" not-null="true" />
<one-to-many class="my.app.OutsourcedProductReceipt" />
</set>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="my.app.OutsourcedProductReceipt" table="outsourced_product_receipt">
<id name="id" column="id">
<generator class="native" />
</id>
<many-to-one name="parentId" class="my.app.OutsourcedProduct" column="parentId" not-null="true" />
</class>
</hibernate-mapping>

I want to access the vendor name of 'OutsourcedProduct' from 'OutsourcedProductReceipt'

outsourcedProductReceiptEntry.getParentId().getToBeRepairedBy().getVendorName()

What changes is required in the following query or in pojos and mpping files to acces the vendor name of OutsourcedProduct?

query = _sessionFactory.getCurrentSession().createQuery("from
OutsourcedProduct inner join fetch utsourcedProduct.parentId
inner join fetch outsourcedProduct.toBeRepairedBy
where outsourcedProduct.parentId = :parentId order by
outsourcedProduct.id");

Any help on this is greatly appreciated.

Thanking you.

Sudheer Palaparambil


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.