protected void beginTransaction() { getDataContext().beginTransaction(); }
protected void beginTransaction() { getDataContext().beginTransaction(); }
protected void beginTransaction() { getDataContext().beginTransaction(); }
public void beginTransaction() { beginTransaction( getDefaultDataConfig().getName() ); }
private ArrayList getSpeciesTypes() throws SQLException, IntactTransactionException { ArrayList species = new ArrayList(); Statement stmt = null; IntactContext.getCurrentInstance().getDataContext().beginTransaction(); try { stmt = getConnection().createStatement(); ResultSet rs = stmt.executeQuery("SELECT distinct species " + "FROM ia_payg"); while (rs.next()) { species.add(rs.getString(1)); } } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { } } } IntactContext.getCurrentInstance().getDataContext().commitTransaction(); return species; }
public void beginTransactionManualFlush() { getDefaultDataConfig().setAutoFlush(true); beginTransaction( getDefaultDataConfig().getName() ); }
/** * Drops the current schema, emptying the database */ public static void dropSchema() throws IntactTransactionException { if (log.isDebugEnabled()) log.debug("Droping schema"); DataContext dataContext = IntactContext.getCurrentInstance().getDataContext(); if (dataContext.isTransactionActive()) { throw new IllegalStateException("To drop the schema, the transaction must NOT be active"); } dataContext.beginTransaction(); Configuration cfg = ((AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig()).getConfiguration(); SchemaExport se = new SchemaExport(cfg); se.drop(false, true); dataContext.commitTransaction(); }
/** * 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 void doPayAsYouGo(String species) throws SQLException, IntactTransactionException { IntactContext.getCurrentInstance().getDataContext().beginTransaction(); String nextbait = getNextNode(species); // while we have uncovered node for (int counter = 1; !nextbait.equals(""); counter++) { virtualPullOut(nextbait, counter, species); nextbait = getNextNode(species); } IntactContext.getCurrentInstance().getDataContext().commitTransaction(); }
IntactContext.getCurrentInstance().getDataContext().beginTransaction();
private static void persistSchemaVersion(IntactContext context) { IntactSession session = context.getSession(); SchemaVersion requiredVersion = context.getConfig().getDefaultDataConfig().getMinimumRequiredVersion(); DbInfo dbInfo = new DbInfo(DbInfo.SCHEMA_VERSION, requiredVersion.toString()); if (log.isDebugEnabled()) log.debug("Persisting schema version: " + requiredVersion.toString()); DaoFactory daoFactory = DaoFactory.getCurrentInstance(session, RuntimeConfig.getCurrentInstance(session).getDefaultDataConfig()); context.getDataContext().beginTransaction(); daoFactory.getDbInfoDao().persist(dbInfo); try { context.getDataContext().commitTransaction(); } catch (IntactTransactionException e) { log.error(e); } }
public void exportEntries() throws IndexerException { int current = 0; log.debug( "Starting export of " + count + " interaction(s)." ); while ( current < count ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractionDao idao = daoFactory.getInteractionDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); List<InteractionImpl> interactions = idao.getAll( current, CHUNK_SIZE ); if ( log.isDebugEnabled() ) { log.debug( "Exporting interaction range " + current + ".." + Math.min( count, current + CHUNK_SIZE ) + " out of " + count ); } for ( Interaction interaction : interactions ) { current++; exportEntry( interaction ); } try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } }
public void exportEntries() throws IndexerException { int current = 0; log.debug( "Starting export of " + count + " interactor(s)." ); while ( current < count ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractorDao pdao = daoFactory.getInteractorDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); List<Interactor> interactors = pdao.getInteractorInvolvedInInteraction( current, CHUNK_SIZE ); if ( log.isDebugEnabled() ) { log.debug( "Exporting interactor range " + current + ".." + Math.min( count, current + CHUNK_SIZE ) + " out of " + count ); } for ( Interactor interactor : interactors ) { current++; exportEntry( interactor ); } try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( "Error when closing transaction.", e ); } } }
public void exportEntries() throws IndexerException { int current = 0; log.debug( "Starting export of " + count + " experiment(s)." ); while ( current < count ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ExperimentDao edao = daoFactory.getExperimentDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); List<Experiment> experiments = edao.getAll( current, CHUNK_SIZE ); if ( log.isDebugEnabled() ) { log.debug( "Exporting experiment range " + current + ".." + Math.min( count, current + CHUNK_SIZE ) + " out of " + count ); } for ( Experiment experiment : experiments ) { current++; exportEntry( experiment ); } try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } }
dataContext.beginTransaction(); dataContext.beginTransaction();
public static void saveOrUpdate(IntactObject ... intactObjects) throws PersisterException { boolean inTransaction = IntactContext.getCurrentInstance().getDataContext().isTransactionActive(); if (!inTransaction) IntactContext.getCurrentInstance().getDataContext().beginTransaction(); for (IntactObject intactObject : intactObjects) { Persister persister = persisterFor(intactObject.getClass()); persister.saveOrUpdate(intactObject); } PersisterContext.getInstance().persistAll(); if (!inTransaction) commitTransactionAndRollbackIfNecessary(); }
public static void saveOrUpdate(IntactEntry ... intactEntries) throws PersisterException { for (IntactEntry intactEntry : intactEntries) { boolean inTransaction = IntactContext.getCurrentInstance().getDataContext().isTransactionActive(); if (!inTransaction) IntactContext.getCurrentInstance().getDataContext().beginTransaction(); EntryPersister.getInstance().saveOrUpdate(intactEntry); EntryPersister.getInstance().commit(); if (!inTransaction) commitTransactionAndRollbackIfNecessary(); } }
public int getEntryCount() throws IndexerException { if ( count == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractorDao<InteractorImpl> interactorDao = daoFactory.getInteractorDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); count = interactorDao.countInteractorInvolvedInInteraction(); try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( "Error while closing transaction.", e ); } } return count; }
public int getEntryCount() throws IndexerException { if ( count == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); InteractionDao idao = daoFactory.getInteractionDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); // TODO do not take into account interactor that do not interact. count = idao.countAll(); try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } return count; } }
public int getEntryCount() throws IndexerException { if ( count == null ) { DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ExperimentDao edao = daoFactory.getExperimentDao(); IntactContext.getCurrentInstance().getDataContext().beginTransaction(); // TODO do not take into account interactor that do not interact. count = edao.countAll(); try { IntactContext.getCurrentInstance().getDataContext().commitTransaction(); } catch ( IntactTransactionException e ) { throw new IndexerException( e ); } } return count; } }