Example usage for javax.persistence CascadeType MERGE

List of usage examples for javax.persistence CascadeType MERGE

Introduction

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

Prototype

CascadeType MERGE

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

Click Source Link

Document

Cascade merge operation

Usage

From source file:com.hmsinc.epicenter.model.workflow.Investigation.java

/**
 * @return the createdBy// w ww  .ja va 2s . c  o m
 */
@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY)
@JoinColumn(name = "ID_APP_USER_CREATED_BY", unique = false, nullable = true, insertable = true, updatable = true)
@org.hibernate.annotations.ForeignKey(name = "FK_INVESTIGATION_4")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public EpiCenterUser getCreatedBy() {
    return createdBy;
}

From source file:edu.harvard.med.screensaver.model.AttachedFile.java

@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE })
@JoinColumn(name = "attachedFileTypeId", nullable = false)
@org.hibernate.annotations.ForeignKey(name = "fk_attached_file_to_attached_file_type")
@org.hibernate.annotations.LazyToOne(value = org.hibernate.annotations.LazyToOneOption.PROXY)
@org.hibernate.annotations.Cascade(value = { org.hibernate.annotations.CascadeType.SAVE_UPDATE })
@edu.harvard.med.screensaver.model.annotations.ToOne(unidirectional = true)
public AttachedFileType getFileType() {
    return _fileType;
}

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  ww  w . j  ava  2s. c o m*/
@Override
public FirebirdFile getFile() {
    return file;
}

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

/**
 * @return the authoritativeRegion/*w  ww .j a va 2  s.c  om*/
 */
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
@JoinColumn(name = "ID_GEOGRAPHY", unique = false, nullable = true, insertable = true, updatable = true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@ForeignKey(name = "FK_ORGANIZATION_2")
public Geography getAuthoritativeRegion() {
    return authoritativeRegion;
}

From source file:com.hmsinc.epicenter.model.workflow.Investigation.java

/**
 * @return the organization/*from   w  ww .j  a v a  2 s .  c  o  m*/
 */
@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY)
@JoinColumn(name = "ID_ORGANIZATION", unique = false, nullable = false, insertable = true, updatable = true)
@org.hibernate.annotations.ForeignKey(name = "FK_INVESTIGATION_3")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Organization getOrganization() {
    return organization;
}

From source file:com.impetus.kundera.ejb.EntityManagerImpl.java

@Override
public final <E> E merge(E e) {
    if (e == null) {
        throw new IllegalArgumentException("Entity must not be null.");
    }//from   w ww  . java 2s  .  c om

    // Validate
    metadataManager.validate(e.getClass());

    try {

        List<EnhancedEntity> reachableEntities = entityResolver.resolve(e, CascadeType.MERGE,
                this.client.getType());

        // save each one
        for (EnhancedEntity o : reachableEntities) {
            log.debug("Merging @Entity >> " + o);

            EntityMetadata metadata = metadataManager.getEntityMetadata(o.getEntity().getClass());
            metadata.setDBType(this.client.getType());
            // TODO: throw OptisticLockException if wrong version and optimistic locking enabled

            // fire PreUpdate events
            eventDispatcher.fireEventListeners(metadata, o, PreUpdate.class);

            dataManager.merge(o, metadata);
            getIndexManager().update(metadata, o.getEntity());

            // fire PreUpdate events
            eventDispatcher.fireEventListeners(metadata, o, PostUpdate.class);
        }
    } catch (Exception exp) {
        throw new PersistenceException(exp);
    }

    return e;
}

From source file:com.eryansky.entity.base.User.java

@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
@JoinTable(name = "T_BASE_USER_ORGAN", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = {
        @JoinColumn(name = "ORGAN_ID") })
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = CacheConstants.HIBERNATE_CACHE_BASE)
public List<Organ> getOrgans() {
    return organs;
}

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

/**
 * @return the users/* www.j a va2 s. c om*/
 */
@ManyToMany(cascade = { CascadeType.PERSIST,
        CascadeType.MERGE }, fetch = FetchType.LAZY, targetEntity = EpiCenterUser.class)
@JoinTable(name = "ORGANIZATION_USER", joinColumns = {
        @JoinColumn(name = "ID_ORGANIZATION") }, inverseJoinColumns = { @JoinColumn(name = "ID_APP_USER") })
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public Set<EpiCenterUser> getUsers() {
    return users;
}

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

/**
 * @return issuer organization//from   w  ww. j av a2s  .c o  m
 */
@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:com.hmsinc.epicenter.model.surveillance.SurveillanceTask.java

/**
 * @return the methods//from w  w w.ja v a 2 s  . c  o  m
 */
@ManyToMany(cascade = { CascadeType.PERSIST,
        CascadeType.MERGE }, fetch = FetchType.LAZY, targetEntity = SurveillanceMethod.class)
@JoinTable(name = "SURVEILLANCE_TASK_METHOD", joinColumns = {
        @JoinColumn(name = "ID_SURVEILLANCE_TASK") }, inverseJoinColumns = {
                @JoinColumn(name = "ID_SURVEILLANCE_METHOD") })
@ForeignKey(name = "FK_SURVEILLANCE_TASK_METHOD_1", inverseName = "FK_SURVEILLANCE_TASK_METHOD_2")
public Set<SurveillanceMethod> getMethods() {
    return methods;
}