Example usage for javax.persistence CascadeType REFRESH

List of usage examples for javax.persistence CascadeType REFRESH

Introduction

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

Prototype

CascadeType REFRESH

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

Click Source Link

Document

Cascade refresh operation

Usage

From source file:com.impetus.kundera.lifecycle.states.NodeState.java

/**
 * @param nodeStateContext//w  w w .  ja  va2 s. c o m
 */
protected void recursivelyPerformOperation(NodeStateContext nodeStateContext, OPERATION operation) {
    Map<NodeLink, Node> children = nodeStateContext.getChildren();
    if (children != null) {
        for (NodeLink nodeLink : children.keySet()) {
            List<CascadeType> cascadeTypes = (List<CascadeType>) nodeLink.getLinkProperty(LinkProperty.CASCADE);

            switch (operation) {
            case PERSIST:
                if (cascadeTypes.contains(CascadeType.PERSIST) || cascadeTypes.contains(CascadeType.ALL)) {
                    Node childNode = children.get(nodeLink);
                    childNode.persist();
                }
                break;
            case MERGE:
                if (cascadeTypes.contains(CascadeType.MERGE) || cascadeTypes.contains(CascadeType.ALL)) {
                    Node childNode = children.get(nodeLink);
                    childNode.merge();
                }
                break;

            case REMOVE:
                if (cascadeTypes.contains(CascadeType.REMOVE) || cascadeTypes.contains(CascadeType.ALL)) {
                    Node childNode = children.get(nodeLink);
                    childNode.remove();
                }
                break;

            case REFRESH:
                if (cascadeTypes.contains(CascadeType.REFRESH) || cascadeTypes.contains(CascadeType.ALL)) {
                    Node childNode = children.get(nodeLink);
                    childNode.refresh();
                }
                break;
            case DETACH:
                if (cascadeTypes.contains(CascadeType.DETACH) || cascadeTypes.contains(CascadeType.ALL)) {
                    Node childNode = children.get(nodeLink);
                    childNode.detach();
                }
                break;
            }

        }
    }
}

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

/**
 * @return the person/*from w ww. ja v a 2  s . com*/
 */
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, optional = false)
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@ForeignKey(name = "person_association_person_fkey")
public Person getPerson() {
    return person;
}

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

/**
 * @return the organization// w  ww  .  j a v a2 s.  c  om
 */
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@JoinColumn(name = "organization_id")
@ForeignKey(name = "shipping_designee_organization_fkey")
@Valid
@NotNull
public Organization getOrganization() {
    return organization;
}

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

/**
 * @return the organization role/*from w  w w .j  a v a  2  s .  co m*/
 */
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, optional = false)
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@ForeignKey(name = "organization_association_organization_role_fkey")
@JoinColumn(name = "organization_role_id")
public AbstractOrganizationRole getOrganizationRole() {
    return organizationRole;
}

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

@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@JoinColumn(name = "file_id")
@ForeignKey(name = "certificate_firebird_file_fkey")
@NotNull//from  w w w  . j a  v  a2 s . c o  m
@Override
public FirebirdFile getFile() {
    return file;
}

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

/**
 * @return issuer organization//  w ww.  ja  va  2s  .  com
 */
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@JoinColumn(name = "issuer_id")
@ForeignKey(name = "credential_organization_fkey")
public Organization getIssuer() {
    return issuer;
}

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

/**
 * @return the formType/*from w  w  w. j  a  va  2 s  .  c  om*/
 */
@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:gov.nih.nci.firebird.data.Protocol.java

/**
 * @return sponsor organization./*w ww . 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:gov.nih.nci.firebird.data.AbstractRegistration.java

/**
 * @return the investigator's profile, if known.
 *///from   w ww .j  ava 2  s .com
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "investigator_profile_id")
@ForeignKey(name = "registration_investigatorprofile_fkey")
@Cascade({ org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.MERGE,
        org.hibernate.annotations.CascadeType.REFRESH })
@NotNull
public InvestigatorProfile getProfile() {
    return profile;
}

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[] {});
}