Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. @Entity
  2. public class Destination implements Serializable {
  3. private static final long serialVersionUID = 1L;
  4.  
  5. @Id
  6. @GeneratedValue(strategy=GenerationType.IDENTITY)
  7. @Column(name="id_destination")
  8. private Long idDestination;
  9.  
  10. //Outros campos...
  11.  
  12. @OneToMany(cascade=CascadeType.PERSIST)
  13. @JoinColumn(name="fk_destination")
  14. private Set<Image> images;
  15. //Getter e Setter
  16.  
  17. @Entity
  18. public class Image implements Serializable{
  19. private static final long serialVersionUID = 1L;
  20.  
  21. @Id
  22. @GeneratedValue(strategy=GenerationType.IDENTITY)
  23. private Long id;
  24. @Column(name="json", length=300)
  25. private String json;
  26. @Column(name="tenant_id", insertable=false, updatable=false)
  27. private Long tenantId;
  28.  
  29. public Image(){
  30.  
  31. }
  32.  
  33. public String getJson() {
  34. return json;
  35. }
  36.  
  37. public void setJson(String gson) {
  38. this.json = gson;
  39. }
  40.  
  41. public Long getId() {
  42. return id;
  43. }
  44.  
  45. public Long getTenantId() {
  46. return tenantId;
  47. }
  48. }
  49.  
  50. //Supondo que passo o id via harded-code na qual tenho um um service que irá me retornar os destinos
  51. Destination destination = dashboardFacade.getDestinationId(4);
  52.  
  53. Set<Image> images = destination.getImages();
  54.  
  55. @OneToMany(cascade=CascadeType.PERSIST, fetch=FetchType.EAGER)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement