-->
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.  [ 3 posts ] 
Author Message
 Post subject: Join Query
PostPosted: Fri Aug 02, 2013 8:13 am 
Newbie

Joined: Fri Aug 02, 2013 8:03 am
Posts: 3
All,

I am pretty much new to Hibernate but have a project to do so hope will get some help from here.

I have a SQL query like

SELECT FIELD_KEY,FIELD_VALUE FROM TBL_FIELD_DATA, TBL_FEATURE_MASTER
WHERE TBL_FEATURE_MASTER.FEATURE_ID = @FEATURE_ID
AND TBL_FEATURE_MASTER.FIELD_ID = TBL_FIELD_DATA.FIELD_ID
AND TBL_FEATURE_MASTER.FLOW_CODE = @FLOW_CODE;

And I have written the relevant HQL as

select FD.fieldDataCompoundkey.Field_key, FD.Field_Value from FieldData FD,FeatureMaster FM where "
+"FM.featureId =? and FM.fieldId=FD.fieldDataCompoundkey.Field_ID and FM.flowCode =?


But i am getting an exception like
Exception : java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.hibernate.db.tables.FieldData
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.hibernate.db.tables.FieldData
at com.hibernate.test.Test.main(Test.java:139)

I know that the query is returning me objects of different class [See below from Log] how do i resolve this.

com.hibernate.db.tables.FieldData{Field_Value=EmergencyFlow_1.wav, fieldDataCompoundkey=component[Field_ID,Field_key]{Field_ID=IND_TAM_GEN_EmergencyFlow, Field_key=Emergency_Prompt}, Field_Description=Configure Emergency Prompt if Enabled}
16:47:09,962 DEBUG Printer:90 - com.hibernate.db.tables.FieldData{Field_Value=True, fieldDataCompoundkey=component[Field_ID,Field_key]{Field_ID=IND_TAM_GEN_EmergencyFlow, Field_key=Emergency_Flag}, Field_Description=Configure Emergency Prompt if Enabled

Any help is much appreciated.


Rgds/binny


Top
 Profile  
 
 Post subject: Re: Join Query
PostPosted: Mon Aug 05, 2013 5:44 am 
Beginner
Beginner

Joined: Wed Feb 06, 2013 2:43 am
Posts: 46
can i have you class object names for TBL_FEATURE_MASTER.FIELD_ID and TBL_FIELD_DATA.FIELD_ID ?

If i guess the names are TBL_FEATURE_MASTER.FIELD_ID = fieldId
TBL_FIELD_DATA.FIELD_ID = fieldId

then the query should be :

select FD.fieldKey, FD.fieldValue from FieldData FD,FeatureMaster FM
where FM.featureId =?
and FM.fieldId=FD.fieldId
and FM.flowCode =?

_________________
Thanks,
Ajit Singh
ajits@mindfiresolutions.com
www.mindfiresolutions.com


Top
 Profile  
 
 Post subject: Re: Join Query
PostPosted: Mon Aug 05, 2013 5:56 am 
Newbie

Joined: Fri Aug 02, 2013 8:03 am
Posts: 3
Thanks for responding Ajith,

I figured out what wrong was i doing and achieved the output via a Criteria Query.

Ajith,

Have you worked on the Cache functionality of Hibernate? If so i have a concern and have also posted it on the forums can you check and see if it makes any sense to you.

https://forum.hibernate.org/viewtopic.php?f=1&t=1027929

Thanks again.

Rgds/Binny


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

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.