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:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer.java

/**
 * Serialize cascades.//from w  w w  .  ja  v  a  2 s  .c o m
 */
private void serializeCascades(ValueMetaData vmd, AnnotationBuilder ab) {
    EnumSet<CascadeType> cascades = EnumSet.noneOf(CascadeType.class);
    if (vmd.getCascadePersist() == ValueMetaData.CASCADE_IMMEDIATE) {
        cascades.add(CascadeType.PERSIST);
    }
    if (vmd.getCascadeAttach() == ValueMetaData.CASCADE_IMMEDIATE) {
        cascades.add(CascadeType.MERGE);
    }
    if (vmd.getCascadeDelete() == ValueMetaData.CASCADE_IMMEDIATE) {
        cascades.add(CascadeType.REMOVE);
    }
    if (vmd.getCascadeRefresh() == ValueMetaData.CASCADE_IMMEDIATE) {
        cascades.add(CascadeType.REFRESH);
    }
    if (vmd.getCascadeDetach() == ValueMetaData.CASCADE_IMMEDIATE) {
        cascades.add(CascadeType.DETACH);
    }
    if (cascades.size() == 5) // ALL
    {
        cascades.clear();
        cascades.add(CascadeType.ALL);
    }
    if (!cascades.isEmpty()) {
        ab.add("cascade", cascades);
    }
}

From source file:org.batoo.jpa.core.impl.model.mapping.AssociationMapping.java

/**
 * @param parent/*from   w  ww  .j a  v  a 2 s  .  c om*/
 *            the parent mapping
 * @param metadata
 *            the metadata
 * @param attribute
 *            the attribute
 * 
 * @since $version
 * @author hceylan
 */
public AssociationMapping(ParentMapping<?, Z> parent, AssociationAttributeMetadata metadata,
        AttributeImpl<? super Z, X> attribute) {
    super(parent, attribute, attribute.getJavaType(), attribute.getName());

    if ((metadata instanceof MappableAssociationAttributeMetadata)
            && StringUtils.isNotBlank(((MappableAssociationAttributeMetadata) metadata).getMappedBy())) {
        this.mappedBy = ((MappableAssociationAttributeMetadata) metadata).getMappedBy();
    } else {
        this.mappedBy = null;
    }

    this.eager = attribute.isCollection() || (this.mappedBy == null)
            ? metadata.getFetchType() == FetchType.EAGER
            : true;

    if (metadata instanceof OrphanableAssociationAttributeMetadata) {
        this.removesOrphans = ((OrphanableAssociationAttributeMetadata) metadata).removesOrphans();
    } else {
        this.removesOrphans = false;
    }

    this.cascadesDetach = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.DETACH);
    this.cascadesMerge = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.MERGE);
    this.cascadesPersist = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.PERSIST);
    this.cascadesRefresh = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.REFRESH);
    this.cascadesRemove = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.REMOVE);
}

From source file:org.batoo.jpa.core.impl.model.mapping.AssociationMappingImpl.java

/**
 * @param parent/*from   ww w. j  ava2  s.  c o  m*/
 *            the parent mapping
 * @param metadata
 *            the metadata
 * @param attribute
 *            the attribute
 * 
 * @since 2.0.0
 */
public AssociationMappingImpl(AbstractParentMapping<?, Z> parent, AssociationAttributeMetadata metadata,
        AttributeImpl<? super Z, X> attribute) {
    super(parent, attribute, attribute.getJavaType(), attribute.getName());

    if ((metadata instanceof MappableAssociationAttributeMetadata)
            && StringUtils.isNotBlank(((MappableAssociationAttributeMetadata) metadata).getMappedBy())) {
        this.mappedBy = ((MappableAssociationAttributeMetadata) metadata).getMappedBy();
    } else {
        this.mappedBy = null;
    }

    this.eager = attribute.isCollection() || (this.mappedBy == null)
            ? metadata.getFetchType() == FetchType.EAGER
            : true;

    this.maxFetchDepth = metadata.getMaxFetchDepth();
    this.fetchStrategy = metadata.getFetchStrategy();

    if (metadata instanceof OrphanableAssociationAttributeMetadata) {
        this.removesOrphans = ((OrphanableAssociationAttributeMetadata) metadata).removesOrphans();
    } else {
        this.removesOrphans = false;
    }

    this.cascadesDetach = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.DETACH);
    this.cascadesMerge = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.MERGE);
    this.cascadesPersist = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.PERSIST);
    this.cascadesRefresh = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.REFRESH);
    this.cascadesRemove = metadata.getCascades().contains(CascadeType.ALL)
            || metadata.getCascades().contains(CascadeType.REMOVE);
}

From source file:org.openremote.beehive.domain.Model.java

@OneToMany(mappedBy = "model", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
public List<RemoteSection> getRemoteSections() {
    return remoteSections;
}

From source file:org.orcid.persistence.jpa.entities.ProfileEntity.java

@OneToMany(mappedBy = "receiver", cascade = { CascadeType.DETACH, CascadeType.REFRESH, CascadeType.REMOVE,
        CascadeType.MERGE })//from  w  w  w .  ja  v  a  2  s  .  co m
public Set<GivenPermissionByEntity> getGivenPermissionBy() {
    return givenPermissionBy;
}

From source file:org.photovault.imginfo.ImageFile.java

/**
 * Get all images stored in this file//from   w ww  .j a  v  a 2s.co  m
 * @return Map that maps image location descriptor to the image descriptor object
 */
@MapKey(name = "locator")
@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE }, mappedBy = "file")
@org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.SAVE_UPDATE,
        org.hibernate.annotations.CascadeType.DELETE })
public Map<String, ImageDescriptorBase> getImages() {
    return images;
}

From source file:velo.entity.Resource.java

/**
 * Get a list of accounts entities related to the Resource
 * /*ww  w  .  ja  v a2  s. co m*/
 * @return A list of accounts
 */
@OneToMany(cascade = CascadeType.REMOVE, mappedBy = "resource", fetch = FetchType.LAZY)
@OrderBy("accountId")
// public Set<Account> getAccounts() {
public Set<Account> getAccounts() {
    return accounts;
}

From source file:velo.entity.Resource.java

/**
 * @return Returns the groups./*from  w w w.j a v  a2 s .  c o m*/
 */
@OneToMany(cascade = CascadeType.REMOVE, mappedBy = "resource", fetch = FetchType.LAZY)
public Set<ResourceGroup> getGroups() {
    return groups;
}

From source file:velo.entity.Resource.java

/**
 * Get a list of ResourceAttribute entities related to this Resource
 * /*from   w ww.j a  v  a  2s .c om*/
 * @return The list of ResourceAttributes
 */
@OneToMany(mappedBy = "resource", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
@OrderBy("priority DESC")
@Deprecated //never use this directly externally, use getAttributes() instead!
public Set<ResourceAttribute> getResourceAttributes() {
    return resourceAttributes;
}

From source file:velo.entity.Resource.java

/**
 * @return the resourceActions/*from   w  ww.j a  v  a2  s.c o  m*/
 */
@OneToMany(mappedBy = "resource", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("description")
public Set<ResourceAction> getResourceActions() {
    return resourceActions;
}