i have many to many relation ship between two table and jenerate new join table in hibernate now how can i insert record in join table by updatation of both table say two table are tbluser and tbldomain i have to insert record in tbluserdomainrelation from both side(that is from tbluser and tbldomain)
at present i can insert record in join table only when i save or update tbluser but i want record to be inserted when i update relationship in domain table also so plese help
in user.class i have written @ManyToMany(targetEntity = VirtualDomain.class, cascade = {CascadeType.PERSIST, CascadeType.MERGE},fetch=FetchType.EAGER)
@JoinTable(name = "tblUserDomainRel", joinColumns = @JoinColumn(name = "userid"), inverseJoinColumns = @JoinColumn(name = "domainid"))
public Set getVirtualdomainset() { return virtualdomainset; }
public void setVirtualdomainset(Set virtualdomainset) { this.virtualdomainset = virtualdomainset; }
while in domain table i have entry
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},fetch=FetchType.EAGER, mappedBy = "virtualdomainset", targetEntity = User.class)
public Set getUserset() { return userset; }
public void setUserset(Set userset) { this.userset = userset; }