-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate is not clearing set of Abstract Classes.
PostPosted: Sat Feb 14, 2009 7:17 am 
Newbie

Joined: Thu May 29, 2008 6:24 am
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2009 1:26 pm 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
Have you looked into the delete-orphan cascade option?

I'm not sure whether it will do what you want, or if it only applies when the owner/parent object is removed.

--
Stephen Souness


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 15, 2009 6:04 am 
Newbie

Joined: Thu May 29, 2008 6:24 am
Posts: 5
hi

your suggestion worked.

thanks
Ankit


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.