List of usage examples for org.springframework.transaction InvalidIsolationLevelException InvalidIsolationLevelException
public InvalidIsolationLevelException(String msg)
From source file:org.springextensions.neodatis.NeoDatisTransactionManager.java
@Override protected void doBegin(Object transaction, TransactionDefinition transactionDefinition) throws TransactionException { if (transactionDefinition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { throw new InvalidIsolationLevelException("NeoDatis does not support an isolation level concept."); }//w w w .ja va2s .c o m ODB odb = null; try { NeoDatisTransactionObject transactionObject = (NeoDatisTransactionObject) transaction; if (transactionObject.getODBHolder() == null) { odb = getOdb(); logger.debug("Using given ODB [{}] for the current thread transaction.", odb); transactionObject.setODBHolder(new ODBHolder(odb)); } ODBHolder odbHolder = transactionObject.getODBHolder(); odbHolder.setSynchronizedWithTransaction(true); // start transaction // no-op // register timeout if (transactionDefinition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) { transactionObject.getODBHolder().setTimeoutInSeconds(transactionDefinition.getTimeout()); } //Bind session holder to the thread TransactionSynchronizationManager.bindResource(getOdb(), odbHolder); } catch (Exception e) { throw new CannotCreateTransactionException("Can not create an NeoDatis transaction.", e); } }
From source file:org.springextensions.db4o.Db4oTransactionManager.java
protected void doBegin(Object transaction, TransactionDefinition transactionDefinition) throws TransactionException { if (transactionDefinition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { throw new InvalidIsolationLevelException("Db4o does not support an isolation level concept"); }/* w w w . ja v a 2s . c o m*/ ObjectContainer container = null; try { Db4oTransactionObject txObject = (Db4oTransactionObject) transaction; if (txObject.getObjectContainerHolder() == null) { // use the given container container = getObjectContainer(); logger.debug("Using given objectContainer [{}] for the current thread transaction", container); txObject.setObjectContainerHolder(new ObjectContainerHolder(container)); } ObjectContainerHolder containerHolder = txObject.getObjectContainerHolder(); containerHolder.setSynchronizedWithTransaction(true); /* * We have no notion of flushing inside a db4o object container * if (transactionDefinition.isReadOnly() && txObject.isNewObjectContainerHolder()) { containerHolder.setReadOnly(true); } if (!transactionDefinition.isReadOnly() && !txObject.isNewObjectContainerHolder()) { if (containerHolder.isReadOnly()) { containerHolder.setReadOnly(false); } } */ // start the transaction // no-op // Register transaction timeout. if (transactionDefinition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) { txObject.getObjectContainerHolder().setTimeoutInSeconds(transactionDefinition.getTimeout()); } // Bind the session holder to the thread. TransactionSynchronizationManager.bindResource(getObjectContainer(), containerHolder); } catch (Exception ex) { throw new CannotCreateTransactionException("Could not start db4o object container transaction", ex); } }
From source file:com.newmainsoftech.spray.slingong.datastore.Slim3PlatformTransactionManager.java
protected void validateIsolationLevel(final int isolationLevel) throws TransactionException { if ((isolationLevel != TransactionDefinition.ISOLATION_DEFAULT) && (isolationLevel != TransactionDefinition.ISOLATION_SERIALIZABLE)) { throw new InvalidIsolationLevelException(String.format( "%1$d is not among the supported isolation levels; " + "only ISOLATION_DEFAULT (%2$d) and ISOLATION_SERIALIZABLE (%3$d) are supported.", isolationLevel, TransactionDefinition.ISOLATION_DEFAULT, TransactionDefinition.ISOLATION_SERIALIZABLE)); }//from ww w . j ava2 s . co m }
From source file:org.springframework.orm.jdo.DefaultJdoDialect.java
/** * This implementation invokes the standard JDO <code>Transaction.begin</code> * method. Throws an InvalidIsolationLevelException if a non-default isolation * level is set.//from w w w .jav a2 s . c o m * @see javax.jdo.Transaction#begin * @see org.springframework.transaction.InvalidIsolationLevelException */ public Object beginTransaction(Transaction transaction, TransactionDefinition definition) throws JDOException, SQLException, TransactionException { if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { throw new InvalidIsolationLevelException("Standard JDO does not support custom isolation levels: " + "use a special JdoDialect implementation for your JDO provider"); } transaction.begin(); return null; }
From source file:org.springframework.orm.jpa.vendor.HibernateJpaDialect.java
@Override public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException { Session session = getSession(entityManager); if (definition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) { session.getTransaction().setTimeout(definition.getTimeout()); }//from w ww . ja v a 2s .com boolean isolationLevelNeeded = (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT); Integer previousIsolationLevel = null; Connection preparedCon = null; if (isolationLevelNeeded || definition.isReadOnly()) { if (this.prepareConnection) { preparedCon = HibernateConnectionHandle.doGetConnection(session); previousIsolationLevel = DataSourceUtils.prepareConnectionForTransaction(preparedCon, definition); } else if (isolationLevelNeeded) { throw new InvalidIsolationLevelException(getClass().getSimpleName() + " does not support custom isolation levels since the 'prepareConnection' flag is off."); } } // Standard JPA transaction begin call for full JPA context setup... entityManager.getTransaction().begin(); // Adapt flush mode and store previous isolation level, if any. FlushMode previousFlushMode = prepareFlushMode(session, definition.isReadOnly()); return new SessionTransactionData(session, previousFlushMode, preparedCon, previousIsolationLevel); }