public IntactTransaction beginTransaction() { log.debug( "Starting transaction..." ); Transaction transaction = getCurrentSession().beginTransaction(); // wrap it currentTransaction = new IntactTransaction( intactSession, transaction ); return currentTransaction; }
@Override public String toString() { return "Transaction [id="+getId()+", committed="+wasCommitted()+"];"; } }
IntactTransaction tx = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentTransaction(); try { tx.commit(); } catch ( IntactTransactionException ie ) { log.error( "Exception commiting " + ie ); try { tx.rollback(); } catch ( IntactTransactionException i ) { log.error( "Exception rolling back " + ie );
log.debug( "Commiting local transaction..." ); try { transaction.commit(); } catch ( IntactTransactionException e ) { throw new BioSourceServiceException( "Error while commiting transaction", e );
log.error( "Exception commiting trying to commit : ", e ); try { context.getDataContext().getDaoFactory().getCurrentTransaction().rollback(); } catch ( Exception ie ) { log.error( "Couldn't rollback." + ie );
public boolean isTransactionActive() { boolean active = ( currentTransaction != null && !currentTransaction.wasCommitted() ); if( log.isDebugEnabled() ) { log.debug( "Current transaction is " + (currentTransaction == null ? "null" : ( active ? "active" : "committed" ) ) ); } return active; }
public void commitAllActiveTransactions() throws IntactTransactionException { Collection<DataConfig> dataConfigs = RuntimeConfig.getCurrentInstance( session ).getDataConfigs(); for ( DataConfig dataConfig : dataConfigs ) { DaoFactory daoFactory = getDaoFactory( dataConfig ); if ( daoFactory.isTransactionActive() ) { daoFactory.getCurrentTransaction().commit(); } } }
private static void commitTransactionAndRollbackIfNecessary() throws PersisterException { try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch (IntactTransactionException e) { try { IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentTransaction().rollback(); } catch (IntactTransactionException e1) { throw new PersisterException(e1); } } } }
public void commit() throws IntactTransactionException { log.debug( "Committing transaction" ); try { transaction.commit(); } catch ( HibernateException e ) { throw new IntactTransactionException( "Commit exception", e ); } assert ( wasCommitted() ); log.debug( "Transaction committed" ); }
public void commitTransaction( String dataConfigName ) throws IntactTransactionException { DaoFactory daoFactory = getDaoFactory( dataConfigName ); if ( daoFactory.isTransactionActive() ) { try { if (getSession().getFlushMode() == FlushMode.MANUAL) { flushSession(); } daoFactory.getCurrentTransaction().commit(); } catch ( IntactTransactionException e ) { log.debug( "An Exception occured commiting" + e.getMessage() ); throw new IntactTransactionException( e ); } if ( log.isDebugEnabled() ) { log.debug( "Committed transaction: " + dataConfigName ); } } assert ( daoFactory.isTransactionActive() == false ); // flush the CvContext in to avoid lazy initialization errors clearCvContext(); }
log.debug( "Commiting local transaction..." ); try { transaction.commit(); } catch ( IntactTransactionException e ) { throw new BioSourceServiceException( "Error while commiting transaction", e );
private static void checkSchemaCompatibility( DataConfig dataConfig, IntactSession session ) { SchemaVersion requiredVersion = dataConfig.getMinimumRequiredVersion(); DaoFactory daoFactory = DaoFactory.getCurrentInstance( session, RuntimeConfig.getCurrentInstance( session ).getDefaultDataConfig() ); IntactTransaction tx = daoFactory.beginTransaction(); DbInfo dbInfoSchemaVersion = daoFactory.getDbInfoDao().get( DbInfo.SCHEMA_VERSION ); try { tx.commit(); } catch ( IntactTransactionException e ) { log.error( "Exception commiting " + e ); } SchemaVersion schemaVersion; if ( dbInfoSchemaVersion == null ) { log.warn( "Schema version does not exist. Will be created" ); setSchemaVersionToBePersisted( session ); return; } try { schemaVersion = SchemaVersion.parse( dbInfoSchemaVersion.getValue() ); } catch ( Exception e ) { throw new IntactInitializationError( "Error getting schema version", e ); } log.info( "Schema Version: " + schemaVersion ); if ( !schemaVersion.isCompatibleWith( requiredVersion ) ) { throw new IntactInitializationError( "Database schema version " + requiredVersion + " is required" + " to use this version of intact-core. Schema version found: " + schemaVersion ); } }
.getInstitutionDao().getByShortLabel( institutionLabel ); try { tx.commit(); } catch ( IntactTransactionException e ) { log.error( "Exception commiting " + e );