Example usage for javax.persistence FlushModeType COMMIT

List of usage examples for javax.persistence FlushModeType COMMIT

Introduction

In this page you can find the example usage for javax.persistence FlushModeType COMMIT.

Prototype

FlushModeType COMMIT

To view the source code for javax.persistence FlushModeType COMMIT.

Click Source Link

Document

Flushing to occur at transaction commit.

Usage

From source file:uk.ac.ebi.intact.dataexchange.cvutils.CvUpdater.java

@Transactional
@IntactFlushMode(FlushModeType.COMMIT)
public CvUpdaterStatistics executeUpdate(OBOSession oboSession, AnnotationInfoDataset annotationInfoDataset)
        throws IOException {
    CvObjectOntologyBuilder builder = new CvObjectOntologyBuilder(oboSession);
    return createOrUpdateCVs(builder.getAllCvs(), annotationInfoDataset);
}

From source file:uk.ac.ebi.intact.dataexchange.cvutils.CvUpdater.java

@Transactional
@IntactFlushMode(FlushModeType.COMMIT)
public CvUpdaterStatistics executeUpdate(OBOSession oboSession) throws IOException {
    return executeUpdate(oboSession, new AnnotationInfoDataset());
}

From source file:uk.ac.ebi.intact.dataexchange.cvutils.CvUpdater.java

/**
 * Starts the creation and update of CVs by using the CVobject List provided
 *
 * @param allValidCvs           List of all valid  Cvs
 * @param annotationInfoDataset A seperate dataset specific for intact
 * @return An object containing some statistics about the update
 *//*from   w ww .ja  v  a  2 s. co m*/
@Transactional
@IntactFlushMode(FlushModeType.COMMIT)
public CvUpdaterStatistics createOrUpdateCVs(List<CvDagObject> allValidCvs,
        AnnotationInfoDataset annotationInfoDataset) {

    if (allValidCvs == null) {
        throw new IllegalArgumentException("You must give a non null collection of CvDagObject");
    }
    if (annotationInfoDataset == null) {
        throw new IllegalArgumentException("You must give a non null AnnotationInfoDataset");
    }

    List<CvDagObject> alreadyExistingObsoleteCvList = new ArrayList<CvDagObject>();
    List<CvDagObject> orphanCvList = dealWithOrphans(allValidCvs, alreadyExistingObsoleteCvList);

    if (log.isDebugEnabled()) {
        log.debug("Orphan count: " + orphanCvList.size());
        log.debug("AlreadyExisting cvs annotated with Obsolete: " + alreadyExistingObsoleteCvList.size());
    }

    //first step remove the orphan cvs that are not existing in database
    List<CvDagObject> cleanedList = (List<CvDagObject>) CollectionUtils.subtract(allValidCvs, orphanCvList);
    if (log.isDebugEnabled())
        log.debug("Size of CV list after removing orphans: " + cleanedList.size());
    //second step remove the orphan cvs that are are already existing in the database
    cleanedList = (List<CvDagObject>) CollectionUtils.subtract(cleanedList, alreadyExistingObsoleteCvList);

    if (log.isDebugEnabled())
        log.debug("Size of CV list after removing obsolete terms: " + cleanedList.size());

    CorePersister corePersister = persisterHelper.getCorePersister();
    corePersister.setUpdateWithoutAcEnabled(true);

    updateCVsUsingAnnotationDataset(cleanedList, annotationInfoDataset, corePersister);

    CvObject[] cvObjects = cleanedList.toArray(new CvObject[cleanedList.size()]);

    corePersister.saveOrUpdate(cvObjects);

    PersisterStatistics persisterStats = corePersister.getStatistics();

    addCvObjectsToUpdaterStats(persisterStats, stats);

    if (log.isDebugEnabled()) {
        log.debug("Persisted: " + persisterStats);
        log.debug("Processed: " + processed.size());
        log.debug(stats);
    }

    return stats;
}