• 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

Create Criteria in Hibernate

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a DO class and having properties like int, long and Set.
i want to access all these properties using projections. i can able to get only for int, long and not for Set. when i exceuted this one getting NullPointerException for Set. please give me suggession to resolve this problem.
List clientAccountIter = (List) session.createCriteria
(ClientAccount.class)
.setProjection(Projections.projectionList()
.add(Projections.property("clientAccount.clientAcctId"))
.add(Projections.property("clientAccount.clientAcctNum"))
.add(Projections.property("clientAccount.clientAccounts")))
.add(Restrictions.eq("registrationReference.regRefId", regRefId))
.list();
here i can get the values for clientAcctId, clientAcctNum and not for clientAccounts. clientAccounts is a Collection property
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to get client accounts, the query will need a join, and to do joins in Criteria, if I recall was either addEntity, or was it addCriteria(). Anyway, you need to use the join style for Criteria.

I am a little bit confused as to why you are using projections?

Mark
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic