Hi, I have two foreign keys which I don't know how to map. Can anybody help me?
1) FOREIGN KEY (postalcode) REFERENCES city_postalcode (id) ON DELETE CASCADE
@ManyToOne(cascade=CascadeType.REMOVE,optional=false,fetch=FetchType.LAZY) @Cascade({org.hibernate.annotations.CascadeType.REMOVE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) @JoinColumn(name="country", nullable=false, updatable=true) public Country getCountry() { return country; }
2) FOREIGN KEY (createdby) REFERENCES uservm(id) ON DELETE SET NULL @ManyToOne(optional=true,fetch=FetchType.LAZY) @JoinColumn(name="createdby", nullable=true, updatable=true) public UserVM getCreatedBy() { return createdBy; }
Also, what is the difference between REMOVE and DELETE_ORPHAN options?
Thanks in advance
|