Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. public class Products {
  2. @OneToMany(mappedBy = "parentId")
  3. private List<Products> productsList;
  4.  
  5. private static final long serialVersionUID = 1L;
  6.  
  7. @Id
  8. @NotNull
  9. @Column(name = "ID")
  10. private String id;
  11. @Column(name = "CODE")
  12. private String code;
  13. @JoinColumn(name = "PARENT_CODE", referencedColumnName = "CODE")
  14. @ManyToOne
  15. private Products parentId;
  16. @Size(max = 1000)
  17. @Column(name = "NAME")
  18. private String name;
  19. @JoinColumn(name = "UNIT_ID", referencedColumnName = "ID", insertable=false, updatable=true)
  20. @ManyToOne(optional = false, fetch = FetchType.LAZY)
  21. private Unit unitId;
  22.  
  23. public class Unit implements Serializable {
  24.  
  25. private static final long serialVersionUID = 1L;
  26.  
  27. @Id
  28. @GeneratedValue(strategy = GenerationType.IDENTITY)
  29. @Column(name = "ID")
  30. private Long id;
  31. @Basic(optional = false)
  32. @NotNull
  33. @Size(min = 1, max = 25)
  34. @Column(name = "NAME")
  35. private String name;
  36. @OneToMany(mappedBy="unitId", cascade=CascadeType.ALL)
  37. private List<Products> productses;
  38.  
  39. Products products = new Products();
  40. products.setId(createGuid());
  41. products.setCode(gson.getCode());
  42. products.setName(gson.getProductName());
  43. products.setParentId(new Products(gson.getParentId()));
  44. products.setUnitId(new Unit(gson.getUnitName()));
  45. em.persist(products);
  46.  
  47. During synchronization a new object was found through a relationship that was not marked cascade PERSIST: kz.aoz.entity.Unit@7b63132a.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement