Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create Criteria in Hibernate

 
purushotham podaralla
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic