Example usage for javax.persistence CascadeType REMOVE

List of usage examples for javax.persistence CascadeType REMOVE

Introduction

In this page you can find the example usage for javax.persistence CascadeType REMOVE.

Prototype

CascadeType REMOVE

To view the source code for javax.persistence CascadeType REMOVE.

Click Source Link

Document

Cascade remove operation

Usage

From source file:com.infinities.skyport.entity.User.java

@XmlTransient
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user", cascade = CascadeType.REMOVE)
public Set<TaskEvent> getTaskEvents() {
    return this.taskEvents;
}

From source file:com.impetus.ankush.common.domain.Cluster.java

/**
 * Gets the nodes.// www.  j a v  a2s.  c o m
 * 
 * @return the nodes
 */
@OneToMany(mappedBy = CLUSTER_ID, fetch = FetchType.EAGER, cascade = CascadeType.REMOVE)
@JsonIgnore
public Set<Node> getNodes() {
    return nodes;
}

From source file:com.infinities.skyport.entity.User.java

@XmlTransient
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user", cascade = CascadeType.REMOVE)
public Set<Session> getSessions() {
    return this.sessions;
}

From source file:com.dp2345.entity.ProductCategory.java

/**
 * ??//from   w w w.j  av  a  2  s.com
 * 
 * @return ?
 */
@OneToMany(mappedBy = "productCategory", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("order asc")
public Set<ParameterGroup> getParameterGroups() {
    return parameterGroups;
}

From source file:com.hrdb.Employee.java

@JsonIgnoreProperties({ "employeeByManagerId", "employeesForManagerId" })
@JsonInclude(Include.NON_EMPTY)//from  w w w  .  j  a  va 2s . co m
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, mappedBy = "employeeByManagerId")
public List<Employee> getEmployeesForManagerId() {
    return this.employeesForManagerId;
}

From source file:com.impetus.kundera.ejb.EntityManagerImpl.java

@Override
public final void remove(Object e) {
    if (e == null) {
        throw new IllegalArgumentException("Entity must not be null.");
    }/* w ww  . j  av  a2  s. co  m*/

    // Validate
    metadataManager.validate(e.getClass());

    try {

        List<EnhancedEntity> reachableEntities = entityResolver.resolve(e, CascadeType.REMOVE,
                this.client.getType());

        // remove each one
        for (EnhancedEntity o : reachableEntities) {
            log.debug("Removing @Entity >> " + o);

            EntityMetadata m = metadataManager.getEntityMetadata(o.getEntity().getClass());
            m.setDBType(this.client.getType());
            // fire PreRemove events
            eventDispatcher.fireEventListeners(m, o, PreRemove.class);

            session.remove(o.getEntity().getClass(), o.getId());
            dataManager.remove(o, m);
            getIndexManager().remove(m, o.getEntity(), o.getId());

            // fire PostRemove events
            eventDispatcher.fireEventListeners(m, o, PostRemove.class);
        }
    } catch (Exception exp) {
        throw new PersistenceException(exp);
    }
}

From source file:com.eryansky.entity.base.Organ.java

@OneToMany(mappedBy = "parentOrgan", cascade = { CascadeType.REMOVE })
public List<Organ> getSubOrgans() {
    return subOrgans;
}

From source file:com.hrdb.Employee.java

@JsonInclude(Include.NON_EMPTY)
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, mappedBy = "employee")
public List<Vacation> getVacations() {
    return this.vacations;
}

From source file:com.dp2345.entity.ProductCategory.java

/**
 * ?//  w w  w.j a  v  a 2s. co m
 * 
 * @return 
 */
@OneToMany(mappedBy = "productCategory", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("order asc")
public Set<Attribute> getAttributes() {
    return attributes;
}

From source file:org.grails.datastore.mapping.engine.NativeEntryEntityPersister.java

/**
 * Delete collections before owner delete.
 *///from   w w  w  . ja  va2s . c  om
protected void cascadeBeforeDelete(PersistentEntity persistentEntity, EntityAccess entityAccess, K key,
        Object instance) {

    List<PersistentProperty> props = persistentEntity.getPersistentProperties();
    for (PersistentProperty prop : props) {
        String propertyKey = getPropertyKey(prop);

        if (prop instanceof OneToMany) {
            OneToMany oneToMany = (OneToMany) prop;
            if (oneToMany.isOwningSide() && oneToMany.doesCascade(CascadeType.REMOVE)) {
                Object propValue = entityAccess.getProperty(oneToMany.getName());
                if (propValue instanceof Collection) {
                    cascadeDeleteCollection((Collection) propValue);
                }
            }
        } else if (prop instanceof ManyToMany) {
            ManyToMany manyToMany = (ManyToMany) prop;
            if (manyToMany.isOwningSide() && manyToMany.doesCascade(CascadeType.REMOVE)) {
                Object propValue = entityAccess.getProperty(manyToMany.getName());
                if (propValue instanceof Collection) {
                    cascadeDeleteCollection((Collection) propValue);
                }
            }
        }
    }
}