Example usage for javax.persistence CascadeType DETACH

List of usage examples for javax.persistence CascadeType DETACH

Introduction

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

Prototype

CascadeType DETACH

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

Click Source Link

Document

Cascade detach operation

Usage

From source file:org.dspace.orm.entity.Eperson.java

@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
@JoinTable(name = "tasklistitem", joinColumns = {
        @JoinColumn(name = "eperson_id", nullable = false) }, inverseJoinColumns = {
                @JoinColumn(name = "workflow_id", nullable = false) })
public List<WorkFlowItem> getWorkFlowItems() {
    return workFlowItems;
}

From source file:org.dspace.orm.entity.Collection.java

@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
@JoinTable(name = "subscription", joinColumns = {
        @JoinColumn(name = "eperson_id", nullable = false) }, inverseJoinColumns = {
                @JoinColumn(name = "collection_id", nullable = false) })
public List<Eperson> getEpersons() {
    return epersons;
}

From source file:com.openlegacy.enterprise.ide.eclipse.editors.pages.details.jpa.FieldsJpaManyToOneFieldDetailsPage.java

private static String[] getCascadeItems() {
    List<String> list = new ArrayList<String>();
    list.add(CascadeType.ALL.toString());
    list.add(CascadeType.PERSIST.toString());
    list.add(CascadeType.MERGE.toString());
    list.add(CascadeType.REMOVE.toString());
    list.add(CascadeType.REFRESH.toString());
    list.add(CascadeType.DETACH.toString());
    return list.toArray(new String[] {});
}

From source file:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.java

/**
 * Set cascades on relation./*w  ww  .  j av a  2  s  .c o  m*/
 */
private void setCascades(ValueMetaData vmd, CascadeType[] cascades) {
    for (CascadeType cascade : cascades) {
        if (cascade == CascadeType.ALL || cascade == CascadeType.REMOVE)
            vmd.setCascadeDelete(ValueMetaData.CASCADE_IMMEDIATE);
        if (cascade == CascadeType.ALL || cascade == CascadeType.PERSIST)
            vmd.setCascadePersist(ValueMetaData.CASCADE_IMMEDIATE);
        if (cascade == CascadeType.ALL || cascade == CascadeType.MERGE)
            vmd.setCascadeAttach(ValueMetaData.CASCADE_IMMEDIATE);
        if (cascade == CascadeType.ALL || cascade == CascadeType.DETACH)
            vmd.setCascadeDetach(ValueMetaData.CASCADE_IMMEDIATE);
        if (cascade == CascadeType.ALL || cascade == CascadeType.REFRESH)
            vmd.setCascadeRefresh(ValueMetaData.CASCADE_IMMEDIATE);
    }
}

From source file:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer.java

/**
 * Serialize cascades.// w w  w.j av  a  2s  . com
 */
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// w  ww . jav  a  2s.  co m
 *            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/* w  ww  . 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.orcid.persistence.jpa.entities.ProfileEntity.java

@OneToMany(mappedBy = "receiver", cascade = { CascadeType.DETACH, CascadeType.REFRESH, CascadeType.REMOVE,
        CascadeType.MERGE })//  w  w  w  .j  av a2  s. c  o m
public Set<GivenPermissionByEntity> getGivenPermissionBy() {
    return givenPermissionBy;
}