define JPA CascadeType

This commit is contained in:
Peter Hormanns 2012-07-18 16:53:44 +00:00
parent b1945db130
commit 7d895c049e
2 changed files with 4 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -67,7 +68,7 @@ public class Domain extends AbstractEntity {
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)") @Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
private String dnsMaster; private String dnsMaster;
@ManyToMany(fetch=FetchType.EAGER, mappedBy="domains") @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="domains")
private Set<DomainOption> domainOptions; private Set<DomainOption> domainOptions;
public Domain() { public Domain() {

View File

@ -4,6 +4,7 @@ import static javax.persistence.GenerationType.SEQUENCE;
import java.util.Set; import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -34,7 +35,7 @@ public class DomainOption extends AbstractEntity {
@Column(name = "domain_option_name", columnDefinition = "character varying(256)", nullable = false) @Column(name = "domain_option_name", columnDefinition = "character varying(256)", nullable = false)
private String name; private String name;
@ManyToMany(fetch=FetchType.LAZY) @ManyToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@JoinTable(name="domain__domain_option", @JoinTable(name="domain__domain_option",
joinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")}, joinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")},
inverseJoinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")}) inverseJoinColumns={@JoinColumn(name="domain_id", referencedColumnName="domain_id")})