Following in my Mapping
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class ProfileRule implements Comparable<ProfileRule> {
public static enum RULE_FLAG {
Include, Exclude, Remove
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "RULE_ID")
private Long id;
@ManyToOne
@JoinColumn(name = "PROFILE_ID", nullable = false)
private Profile profile;
@Entity
@Table(name = "AS_MON_RULE")
public class MonRule extends ProfileRule {
public static enum MON_RULE_TYPE {
File("file", "File"), Registry("reg", "Registry"), Extension("extn", "Extn"), Process("process", "Process"), User(
"user", "User"), Procexec("procexec", "Procexec");
private final String ssCommand;
private final String display;
// Constructor
MON_RULE_TYPE(final String command, final String display) {
ssCommand = command;
this.display = display;
}
public String getCommandString() {
return ssCommand;
}
public String getDisplayString() {
return display;
}
}
@Column(name = "NAME", length = 1024, nullable = false)
private String name;
@Enumerated(EnumType.STRING)
@Column(name = "RULE_TYPE", length = 64, nullable = false)
private MON_RULE_TYPE monRuleType = null;
@Enumerated(EnumType.STRING)
@Column(name = "RULE_FLAG", length = 64, nullable = false)
private ProfileRule.RULE_FLAG flag = null;
public MonRule() {
}
@Entity
@Table(name = "AS_PROFILE", uniqueConstraints = { @UniqueConstraint(columnNames = { "NAME" }) })
public class Profile implements HasCustomer, BaseVO<ProfileVO> {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private Long id;
@Column(name = "NAME", length = 128, nullable = false)
private String name;
@Column(name = "DESCRIPTION", length = 128, nullable = false)
private String description;
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "profile")
private Set<ProfileRule> rules = null;
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinTable(name = "AS_PROFILE_SS_ASSOC", joinColumns = @JoinColumn(name = "PROFILE_ID"), inverseJoinColumns = @JoinColumn(name = "SS_ID"))
private Set<Solidifier> solidifiers = new HashSet<Solidifier>();
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinTable(name = "AS_PROFILE_SS_GRP_ASSOC", joinColumns = @JoinColumn(name = "PROFILE_ID"), inverseJoinColumns = @JoinColumn(name = "GROUP_ID"))
private Set<SolidifierGroup> solidifierGrps = new HashSet<SolidifierGroup>();
@ManyToOne
@JoinColumn(name = "CUSTOMER_ID")
private Customer customer;
public Set<ProfileRule> getRules() {
return rules;
}
public void clearRules() {
getRules().clear();
}
Here
If i do following
Profile p = DAOFactory.getProfile(id)
p.clearRules();
Here this is not clearing the entries in AS_MON_RULE table.
Can anybody help me in this?
Ankit