Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting values on a object based on returning query [Solved]

 
Oddbjorn Lona
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a query, similar to this:



This basically is returning a list of values from the tablename.

Now, field4 and field5 are underlying objects.

Now, the thing is i cannot use tablename domain directly, so i (think) i need to build this up manually, so what i have is a loop :



How do I populate the values for foo now? I only require a few values, to make a list.

Thanks

 
Oddbjorn Lona
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the answer, which is somewhat of a hack, i admit it:

the return getSession().createQuery(sql.toString()).list() turns out to be a Query.

Then traversing through the query like this, and populating my object.

 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!