• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate join returning a list of objects from one table in the join

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done a couple of projects with hibernate but I can't seem to get this sort of thing to work. I have to classes IncentiveObj and IncentiveOwnerObj I want to return an IncentiveObj for those rows on the IncentiveOwnerObj (related table actually) where the other parts of the where clause are specified that is the first_Name and last_Name match the string's passed. Both share a field called incentive_id which I am joining on.

I have tried different things the last being to create a contructor on the object I want which accepts a paramter but then I get a list of objects with only that field filled. If I add the other columms to the constructor it doesn't work.

Here is the select string I'm passing to the query currently.

private String INCENTIVE_BY_OWNER = "SELECT new com.amfam.isagent.asit.dataObjects.IncentiveObj(i.incentive_Name)" + "from IncentiveObj i," + " IncentiveOwnerObj io " +
"where i.incentive_Id = io.incentive_Id " + " and io.first_Name = 'Kristie'" + " and io.last_Name = 'Sands'";

Can this sort of thing be done without reading the tables independent of each other and iterating through one of the resulting lists and reading the other table?

Thanks,

Chris
 
it's a teeny, tiny, wafer thin ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic