Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. @Entity
  2. @Table(name="lead", uniqueConstraints = { })
  3. public class Lead implements Serializable {
  4.  
  5. private int leadid;
  6.  
  7. // More fields
  8.  
  9. private Set<Lead> duplicateLeadChildren;
  10. private Lead duplicateLeadParent;
  11.  
  12. @Id
  13. @GeneratedValue(strategy=GenerationType.IDENTITY)
  14. @Column(name="leadid", unique=true, nullable=false, insertable=true, updatable=true)
  15. public int getLeadid() {
  16. return this.leadid;
  17. }
  18. public void setLeadid(int leadid) {
  19. this.leadid = leadid;
  20. }
  21.  
  22. // More setters and getters
  23.  
  24. /**
  25. * Returns a set of leads that has been marked as duplicates of this lead.
  26. * @return
  27. */
  28. @OneToMany(fetch=FetchType.LAZY)
  29. @JoinTable(name="leadduplicate"
  30. , joinColumns={@JoinColumn(name="parentleadid")}
  31. , inverseJoinColumns={@JoinColumn(name="childleadid")})
  32. @NotFound(action=NotFoundAction.IGNORE)
  33. public Set<Lead> getDuplicateLeadChildren(){
  34. return duplicateLeadChildren;
  35. }
  36.  
  37. public void setDuplicateLeadChildren(Set<Lead> duplicateLeadChildren) {
  38. this.duplicateLeadChildren = duplicateLeadChildren;
  39. }
  40.  
  41. /**
  42. * Returns a lead if this lead has been marked as a duplicate.
  43. *
  44. * The returned lead is the lead that should be used as the main lead in all future contact with the company.
  45. * @return
  46. */
  47. @ManyToOne(fetch=FetchType.LAZY)
  48. @JoinTable(name="leadduplicate"
  49. , joinColumns={@JoinColumn(name="childleadid")}
  50. , inverseJoinColumns={@JoinColumn(name="parentleadid")})
  51. @NotFound(action=NotFoundAction.IGNORE)
  52. public Lead getDuplicateLeadParent(){
  53. return duplicateLeadParent;
  54. }
  55.  
  56. public void setDuplicateLeadParent(Lead duplicateLeadParent) {
  57. this.duplicateLeadParent = duplicateLeadParent;
  58. }
  59. }
  60.  
  61. final Lead lead = new Lead();
  62. // Removed setting some other fields removed from the class above
  63. session.saveOrUpdate(lead);
  64.  
  65. Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value : se.telavox.tbone.dao.base.Lead.duplicateLeadParent
Add Comment
Please, Sign In to add comment