Posted By

corporem on 09/24/11


Tagged

Hibernate criteria projection


Versions (?)

Hibernate Criteria And Projection


 / Published in: Java
 

  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  

You need to login to post a comment.