Example usage for javax.persistence CascadeType PERSIST

List of usage examples for javax.persistence CascadeType PERSIST

Introduction

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

Prototype

CascadeType PERSIST

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

Click Source Link

Document

Cascade persist operation

Usage

From source file:no.abmu.questionnarie.domain.Account.java

/**
 * @hibernate.set lazy="true"/*  w ww  .  jav a  2  s .  c  o m*/
 * inverse="true"
 * cascade="save-update"
 * table="FINANCE_REPORT_SCHEMA_ACCOUNT"
 * @hibernate.key column="FK_ACCOUNT_ID"
 * @hibernate.many-to-many class="no.abmu.finances.domain.ReportSchema"
 * column="FK_REPORT_SCHEMA_ID"
 * @hibernate.cache usage="nonstrict-read-write"
 * @hibernate.collection-key column="FK_ACCOUNT_ID"
 * @hibernate.collection-many-to-many class="no.abmu.finances.domain.ReportSchema"
 * column="FK_REPORT_SCHEMA_ID"
 */
//    @ManyToMany(cascade = {CascadeType.ALL})
//    @ForeignKey(name = "FK_REPORT_SCHEMA_ID", inverseName = "FK_REPORT_SCHEMA_ID")
//    @JoinTable(
//            name = "QUESTIONNARIE_ACCOUNT_REPORTSCHEMA"
////            schema = "QUESTIONNARIE"
//    )
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER /* TODO FETCH */
)
@JoinTable(
        //            schema = "QUESTIONNARIE"
        name = "QUESTIONNARIE_ACCOUNT_MAIN_REPORT_SCHEMA", joinColumns = {
                @JoinColumn(name = "ACCOUNT_ID") }, inverseJoinColumns = { @JoinColumn(name = "RS_ID") })
//    @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public Set<MainReportSchema> getMainReportSchemas() {
    return mainReportSchemas;
}

From source file:no.abmu.questionnarie.domain.Account.java

@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER /* TODO FETCH */
)
@JoinTable(/*www.j av a  2s.  co m*/
        //            schema = "QUESTIONNARIE"
        name = "QUESTIONNARIE_ACCOUNT_SUB_REPORT_SCHEMA", joinColumns = {
                @JoinColumn(name = "ACCOUNT_ID") }, inverseJoinColumns = { @JoinColumn(name = "RS_ID") })
//    @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public Set<SubReportSchema> getSubReportSchemas() {
    return subReportSchemas;
}

From source file:no.abmu.questionnarie.domain.Post.java

/**
 * @hibernate.set lazy="true"/*from w w w . j  av a  2s  .co  m*/
 * inverse="true"
 * cascade="save-update"
 * table="FINANCE_ACCOUNT_POST"
 * @hibernate.key column="FK_POST_ID"
 * @hibernate.many-to-many class="no.abmu.finances.domain.Account"
 * column="FK_ACCOUNT_ID"
 * @hibernate.cache usage="nonstrict-read-write"
 * @hibernate.collection-key column="FK_POST_ID"
 * @hibernate.collection-many-to-many class="no.abmu.finances.domain.Account"
 * column="FK_ACCOUNT_ID"
 */
//    @ManyToMany(cascade = {CascadeType.ALL})
//    @ForeignKey(name = "FK_ACCOUNT_ID", inverseName = "FK_ACCOUNT_ID")
//    @JoinTable(
//            name = "QUESTIONNARIE_
////            schema = "QUESTIONNARIE"
//    )
@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "posts")
//    @Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public Set<Account> getAccounts() {
    return accounts;
}

From source file:org.apache.camel.bam.model.ActivityState.java

@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
public ProcessInstance getProcessInstance() {
    return processInstance;
}

From source file:org.apache.camel.bam.model.ActivityState.java

@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
public ActivityDefinition getActivityDefinition() {
    return activityDefinition;
}

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

/**
 * Set cascades on relation.//from   ww  w . j  a  v  a  2s. com
 */
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./* www . j a va2 s. 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.apromore.dao.model.ProcessModelVersion.java

@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name = "branchId")
public ProcessBranch getProcessBranch() {
    return this.processBranch;
}

From source file:org.apromore.dao.model.ProcessModelVersion.java

@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name = "rootFragmentVersionId")
public FragmentVersion getRootFragmentVersion() {
    return this.rootFragmentVersion;
}

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

/**
 * @param parent//from  www . ja  v a2 s.  c  o 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);
}