Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. class User {
  2. //some properties
  3. static hasMany=[photos:PhotoUpload]
  4. static mappings={
  5. photos lazy: false
  6. }
  7.  
  8. class LoginController {
  9. ...
  10. def u= User.findByEmailAndPassword(email,password,[fetch: [photos: 'select']]);
  11. if(u!=null) {
  12. session.user=u
  13. session.user=u
  14. chain(action:"login_success")
  15. }else {
  16. chain(action:"login_failure")
  17. }
  18. }
  19.  
  20. def login_success={ render(view: '/user/profile') }
  21. }
  22.  
  23. <h1>${user?.photos==null}</h1>
  24. <!-- I am getting "true" ,if i remove lazy:flalse,fetch:join for photos property
  25. of User,otherwise i am getting Excpetion : org.hibernate.LazyInitializationException-->
  26. <g:each var="photo" in="${session?.user?.photos}">
  27. <div class="row image_container">
  28. <div class="col-xs-12 col-sm-5 col-md-5 col-lg-6 col-lg-offset-3">
  29. <a href="#x">
  30. <img src="data:image/*;base64,${photo.photo.getBytes()}" alt="Image"
  31. class="thumbnail img-responsive" />
  32. </a>
  33. <div class="caption">
  34. <h3 class="reponsive-font">${photo.name}</h3>
  35. <p class="reponsive-font">${photo.description}</p>
  36. </div>
  37. </div>
  38. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement