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:gov.nih.nci.firebird.data.AbstractRegistrationForm.java

/**
 * @return the formType/*  w  w  w .j  a v a  2s.co m*/
 */
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST, CascadeType.MERGE,
        CascadeType.REFRESH }, fetch = FetchType.EAGER)
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@ForeignKey(name = "form_form_type_fkey")
@JoinColumn(name = "form_type_id")
public FormType getFormType() {
    return formType;
}

From source file:com.denimgroup.threadfix.data.entities.Application.java

@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinColumn(name = "grcToolId")
@JsonIgnore
public GRCTool getGrcTool() {
    return grcTool;
}

From source file:com.hmsinc.epicenter.model.provider.Facility.java

/**
 * @return the affiliations//from  w ww . j a v  a 2s.co  m
 */
@ManyToMany(cascade = { CascadeType.PERSIST,
        CascadeType.MERGE }, fetch = FetchType.LAZY, targetEntity = Facility.class)
@JoinTable(name = "FACILITY_AFFILIATION", joinColumns = {
        @JoinColumn(name = "ID_FACILITY") }, inverseJoinColumns = {
                @JoinColumn(name = "ID_FACILITY_AFFILIATION") })
@ForeignKey(name = "FK_FACILITY_AFFILIATION_1", inverseName = "FK_FACILITY_AFFILIATION_2")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<Facility> getAffiliations() {
    return affiliations;
}

From source file:com.denimgroup.threadfix.data.entities.Application.java

@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinColumn(name = "wafId")
@JsonIgnore
public Waf getWaf() {
    return waf;
}

From source file:gov.nih.nci.firebird.data.Protocol.java

/**
 * @return sponsor organization./*from   www .j  a va  2s  .c o  m*/
 */
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@JoinColumn(name = "sponsor_id")
@ForeignKey(name = "protocol_sponsor_fkey")
@NotNull
public Organization getSponsor() {
    return sponsor;
}

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:com.hmsinc.epicenter.model.provider.Facility.java

/**
 * @return the contacts//from  w  ww.j  a v  a  2s  . co m
 */
@ManyToMany(cascade = { CascadeType.PERSIST,
        CascadeType.MERGE }, fetch = FetchType.LAZY, targetEntity = Contact.class)
@JoinTable(name = "FACILITY_CONTACT", joinColumns = {
        @JoinColumn(name = "ID_FACILITY") }, inverseJoinColumns = { @JoinColumn(name = "ID_CONTACT") })
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<Contact> getContacts() {
    return contacts;
}

From source file:com.hmsinc.epicenter.model.provider.Facility.java

/**
 * @return the duas/*from  w ww  .  j  av  a 2 s  .co m*/
 */
@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "facility")
public Set<FacilityDUA> getDuas() {
    return duas;
}

From source file:org.grails.datastore.mapping.gemfire.engine.GemfireEntityPersister.java

private void cascadeSaveOrUpdate(PersistentEntity persistentEntity, Object obj, EntityAccess access) {
    final List<Association> associations = persistentEntity.getAssociations();
    for (Association association : associations) {
        if (association.doesCascade(CascadeType.PERSIST)) {
            @SuppressWarnings("hiding")
            final Session session = getSession();
            String processKey = association + ">" + obj;
            if (association instanceof ToOne) {
                final Object associatedObject = access.getProperty(association.getName());

                if (associatedObject != null && !associatedObject.equals(obj)) {
                    if (session.getAttribute(obj, processKey) == null) {
                        session.setAttribute(obj, processKey, true);
                        this.session.persist(associatedObject);
                        autoAssociateInverseSide(obj, association, associatedObject);
                    }//from  w  ww .  j a v  a 2 s  .co m
                } else {
                    session.setAttribute(obj, processKey, false);
                }
            } else if (association instanceof OneToMany) {
                if (session.getAttribute(obj, processKey) == Boolean.TRUE) {
                    session.setAttribute(obj, processKey, Boolean.TRUE);
                    Object associatedObjects = access.getProperty(association.getName());
                    if (associatedObjects instanceof Iterable) {
                        final Iterable iterable = (Iterable) associatedObjects;
                        for (Object associatedObject : iterable) {
                            autoAssociateInverseSide(obj, association, associatedObject);
                        }
                        session.persist(iterable);
                    }
                } else {
                    session.setAttribute(obj, processKey, false);
                }
            }
        }
    }
}

From source file:com.hmsinc.epicenter.model.permission.EpiCenterUser.java

/**
 * @return the roles// www  .j  a  v  a  2 s.  c  o  m
 */
@ManyToMany(cascade = { CascadeType.PERSIST,
        CascadeType.MERGE }, fetch = FetchType.EAGER, targetEntity = EpiCenterRole.class)
@JoinTable(name = "APP_USER_ROLE", joinColumns = { @JoinColumn(name = "ID_APP_USER") }, inverseJoinColumns = {
        @JoinColumn(name = "ID_APP_ROLE") })
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<EpiCenterRole> getRoles() {
    return roles;
}