my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes Problem in retriveing the values from database using HQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem in retriveing the values from database using HQL" Watch "Problem in retriveing the values from database using HQL" New topic
Author

Problem in retriveing the values from database using HQL

Amith Bhavikatti
Greenhorn

Joined: Oct 27, 2006
Posts: 26
I am fetching all the values from a table called AssignmentByLetter.
but it has one column named CollectorId in which id will be present and it is object of some other table called Collector.

In Collector table i have CollectorId and CollectorName.

CollectorId in AssignmentByLetter has relationship with Collector:
like this:

<many-to-one
name="collector"
class="com.bvn.finance.services.treatment.collectors.Collector"
cascade="all"
outer-join="auto"
update="false"
insert="false"
access="field"
column="tlaCollectorId" />

Now if i type
Query q = session.getNamedQuery("assignmentbyletter_all");
result= q.list();

Return all values and assign to a list,it's not doing that because collectorId in AssignmentByLetter is a object of Collector..
Can anybody solve this issue?
i need a plain list where i should have collectorName instead of CollectorId while fetching from the table..


Please anybody help me...
Thanks in Advance
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"amithbn bn" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Amith Bhavikatti
Greenhorn

Joined: Oct 27, 2006
Posts: 26
Its Now Ok.
Please suggest me on this problem....


Thanks in Advance
Angel Taveras
Ranch Hand

Joined: Nov 13, 2008
Posts: 84

Hello Amith, what you're trying to do it's to return all the collectorName that are associated with the AssignmentByLetter?

Regards
Amith Bhavikatti
Greenhorn

Joined: Oct 27, 2006
Posts: 26
HI Angel,
Thanks for the reply..
I have to diplay Collector names in JSF page using collectorsID from the Table.
If i query the table the collector id will come as a object not as a value..
so please suggest me how to convert that object value returned in to noraml values and add to arraylist..

Thanks in Advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


If i query the table the collector id will come as a object not as a value..
so please suggest me how to convert that object value returned in to noraml values and add to arraylist.

What do you mean by "value"? Were you hoping for a primitive?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Amith Bhavikatti
Greenhorn

Joined: Oct 27, 2006
Posts: 26
database value for that column will come like @com.bvn.finance.services.treatment.collectors.Collector object..

So please tell me how to convert it to my class Collector and assign collector name using collector id from the above object..

Thanks in Advance.....
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What is the difference between your Collector type and com.bvn.finance.services.treatment.collectors.Collector? Why do you need to convert it?
[ December 22, 2008: Message edited by: Paul Sturrock ]
Angel Taveras
Ranch Hand

Joined: Nov 13, 2008
Posts: 84

Amith, i think a query like this,



the above will return all of the com.bvn.finance.services.treatment.collectors.Collector objects as a list. if you want to return all the collectorName that are associated with AssignmentByLetter then you could use this query



I hope this helps,

regards,
[ December 22, 2008: Message edited by: Angel Taveras ]
 
Don't get me started about those stupid light bulbs.
 
subject: Problem in retriveing the values from database using HQL
 
Similar Threads
Can i assign the returned list from hibernate like this
Getting java.lang.ClassCastException.
Caught a NonUnique Exception while adding more rows to the table.
Getting java.lang.ClassCastException.
Getting java.lang.ClassCastException.