@Override public IntactTransaction getCurrentTransaction() { return super.getCurrentTransaction(); }
/** * Drops and creates the schema. Beware that it commits transactions * @param initializeDatabase If false, do not initialize the database (e.g. don't create Institution) */ public static void resetSchema(boolean initializeDatabase) throws IntactTransactionException { if (log.isDebugEnabled()) log.debug("Resetting schema"); DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); if (dataContext.isTransactionActive()) { throw new IllegalStateException("To reset the schema, the transaction must NOT be active: "+dataContext.getDaoFactory().getCurrentTransaction()); } dropSchema(); createSchema(initializeDatabase); } }
log.error( "Exception commiting trying to commit : ", e ); try { context.getDataContext().getDaoFactory().getCurrentTransaction().rollback(); } catch ( Exception ie ) { log.error( "Couldn't rollback." + ie );
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(); } } }
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(); }
IntactTransaction tx = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getCurrentTransaction(); try { tx.commit();
/** * Creates a schema * @param initializeDatabase If false, do not initialize the database (e.g. don't create Institution) */ public static void createSchema(boolean initializeDatabase) throws IntactTransactionException { if (log.isDebugEnabled()) log.debug("Creating schema"); DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); if (dataContext.isTransactionActive()) { throw new IllegalStateException("To reset the schema, the transaction must NOT be active: "+dataContext.getDaoFactory().getCurrentTransaction()); } dataContext.beginTransaction(); Configuration cfg = ((AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig()).getConfiguration(); SchemaExport se = new SchemaExport(cfg); se.create(false, true); dataContext.commitTransaction(); dataContext.beginTransaction(); if (initializeDatabase) { if (log.isDebugEnabled()) log.debug("Initializing database"); IntactConfigurator.initializeDatabase(IntactContext.getCurrentInstance()); } dataContext.commitTransaction(); }
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); } } } }