-->
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: Hibernate Criteria Multiple tables
PostPosted: Tue Jun 21, 2011 7:34 am 
Newbie

Joined: Tue Jun 21, 2011 7:20 am
Posts: 1
Hi i need to get data from two tables, im using hibernate criteria. My scenario is,
Two tables AssetDetails and AssetManage
asset_details contains
    asset_id, asset_name, asset_reference, status, condition, asset_type, vendor, manufacturer, asset_location
asset_manage contains
    manage_id, asset_id, owner, checked_status, description
etc.,
now im working on tracking details of an asset from asset_details table using hibernate criteria. my code looks like,
Code:
session = HibernateSessionFactory.getSession();
Criteria criteria = session.createCriteria(AssetDetails.class);
criteria.add(Expression.in("assetId", action.getSearchAssetIds()));
criteria.add(Expression.in("assetTypes.typeId", action.getSearchAssetTypes()));
criteria.add(Expression.in("assetName", action.getSearchAssetNames()));
criteria.add(Expression.in("selectValueByStatus.selectValueId", action.getSearchAssetStatus()));
criteria.add(Expression.in("selectValueByCondition.selectValueId", action.getSearchAssetCondition()));
assetsList = criteria.list();

all these are fine as they are present in asset_details table, now i want some thing like,
Code:
SELECT * FROM asset_details asd, asset_manage asm where asd.asset_id=asm.asset_id and asm.checked_status='ACTIVE';


asset_manage table contains asset_details as foreign key, but vice-versa is not there. so its becoming problem for me.
Any help appreciated...


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.