Hibernate Criteria And Projection


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public ProfileInfoValueObject loadProfileInformation(Integer memberId) {
  2. ProfileInfoValueObject profileInfo = ((ProfileInfoValueObject)
  3. ((Session) slaveApiEntityManager.getDelegate())
  4. .createCriteria(Nick.class, "n")
  5. .createAlias("n.member", "m")
  6. .createAlias("n.profileDescription", "d", Criteria.LEFT_JOIN)
  7. .createAlias("n.profileImage", "i", Criteria.LEFT_JOIN)
  8. .setProjection(Projections.projectionList()
  9. .add(Projections.property("m.city"), "cityCode")
  10. .add(Projections.property("n.registerDate"),
  11. "registerDate")
  12. .add(Projections.property("n.sml"), "processCount")
  13. .add(Projections.property("i.imageName"), "imageName")
  14. .add(Projections.property("i.status"), "imageStatus")
  15. .add(Projections.property("d.about"), "description")
  16. .add(Projections.property("d.status"),
  17. "descriptionStatus")
  18. )
  19. .add(Restrictions.eq("n.memberId", memberId))
  20.  
  21. .setResultTransformer(Transformers.aliasToBean(ProfileInfoValueObject.class))
  22. .uniqueResult());
  23.  
  24. return profileInfo;
  25. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.