Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in retriveing the values from database using HQL

 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"amithbn bn" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its Now Ok.
Please suggest me on this problem....


Thanks in Advance
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Amith Bhavikatti
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic