Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Products {
- @OneToMany(mappedBy = "parentId")
- private List<Products> productsList;
- private static final long serialVersionUID = 1L;
- @Id
- @NotNull
- @Column(name = "ID")
- private String id;
- @Column(name = "CODE")
- private String code;
- @JoinColumn(name = "PARENT_CODE", referencedColumnName = "CODE")
- @ManyToOne
- private Products parentId;
- @Size(max = 1000)
- @Column(name = "NAME")
- private String name;
- @JoinColumn(name = "UNIT_ID", referencedColumnName = "ID", insertable=false, updatable=true)
- @ManyToOne(optional = false, fetch = FetchType.LAZY)
- private Unit unitId;
- public class Unit implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "ID")
- private Long id;
- @Basic(optional = false)
- @NotNull
- @Size(min = 1, max = 25)
- @Column(name = "NAME")
- private String name;
- @OneToMany(mappedBy="unitId", cascade=CascadeType.ALL)
- private List<Products> productses;
- Products products = new Products();
- products.setId(createGuid());
- products.setCode(gson.getCode());
- products.setName(gson.getProductName());
- products.setParentId(new Products(gson.getParentId()));
- products.setUnitId(new Unit(gson.getUnitName()));
- em.persist(products);
- 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