Example usage for org.hibernate ReplicationMode EXCEPTION

List of usage examples for org.hibernate ReplicationMode EXCEPTION

Introduction

In this page you can find the example usage for org.hibernate ReplicationMode EXCEPTION.

Prototype

ReplicationMode EXCEPTION

To view the source code for org.hibernate ReplicationMode EXCEPTION.

Click Source Link

Document

Throw an exception when a row already exists.

Usage

From source file:com.devnexus.ting.repository.jpa.BaseRepositoryImpl.java

License:Apache License

/** {@inheritDoc} */
@Override//from  ww w.j a va  2 s.co  m
public void replicate(T object) {
    this.entityManager.unwrap(Session.class).replicate(object, ReplicationMode.EXCEPTION);
}

From source file:com.lighting.platform.base.dao.SimpleHibernateDao.java

License:Apache License

/**
 * ?ID?,ID,?
 * ?
 * @param t
 */
public void insertDIYID(final T t) {
    getSession().replicate(t, ReplicationMode.EXCEPTION);
}

From source file:org.candlepin.model.ConsumerCurator.java

License:Open Source License

@Transactional
public Consumer replicate(Consumer consumer) {
    for (Entitlement entitlement : consumer.getEntitlements()) {
        entitlement.setConsumer(consumer);
    }//from   w  ww . j  a  va  2  s . c  o m

    ConsumerType consumerType = consumerTypeCurator.lookupByLabel(consumer.getType().getLabel());
    consumer.setType(consumerType);

    IdentityCertificate idCert = consumer.getIdCert();
    this.currentSession().replicate(idCert.getSerial(), ReplicationMode.EXCEPTION);
    this.currentSession().replicate(idCert, ReplicationMode.EXCEPTION);

    this.currentSession().replicate(consumer, ReplicationMode.EXCEPTION);

    return consumer;
}

From source file:org.candlepin.model.EntitlementCurator.java

License:Open Source License

@Transactional
public Entitlement replicate(Entitlement ent) {
    for (EntitlementCertificate ec : ent.getCertificates()) {
        ec.setEntitlement(ent);//from   w  ww  .j  a v  a2s.  c om
        CertificateSerial cs = ec.getSerial();
        if (cs != null) {
            this.currentSession().replicate(cs, ReplicationMode.EXCEPTION);
        }
    }
    this.currentSession().replicate(ent, ReplicationMode.EXCEPTION);

    return ent;
}

From source file:org.candlepin.model.OwnerCurator.java

License:Open Source License

@Transactional
public Owner replicate(Owner owner) {
    this.currentSession().replicate(owner, ReplicationMode.EXCEPTION);

    return owner;
}

From source file:org.candlepin.model.PoolCurator.java

License:Open Source License

@Transactional
public Pool replicate(Pool pool) {
    for (ProvidedProduct pp : pool.getProvidedProducts()) {
        pp.setPool(pool);/*  w  w  w  .ja  v a 2s  .  c o  m*/
    }

    for (DerivedProvidedProduct dpp : pool.getDerivedProvidedProducts()) {
        dpp.setPool(pool);
    }

    for (PoolAttribute pa : pool.getAttributes()) {
        pa.setPool(pool);
    }

    for (ProductPoolAttribute ppa : pool.getProductAttributes()) {
        ppa.setPool(pool);
    }

    for (DerivedProductPoolAttribute dppa : pool.getDerivedProductAttributes()) {
        dppa.setPool(pool);
    }

    // Looks like this is restored in MigrateOwnerJob.replicateEntitlements:
    pool.setSourceEntitlement(null);

    this.currentSession().replicate(pool, ReplicationMode.EXCEPTION);

    return pool;
}