public void remove(Object entity) { checkTransactionNeeded(); //adjustFlushMode(); try { getSession().delete( entity ); } catch (MappingException e) { throw new IllegalArgumentException( e.getMessage(), e ); } catch (HibernateException he) { throwPersistenceException( he ); } }
public void lock(Object entity, LockModeType lockMode) { try { if ( ! isTransactionInProgress() ) { throw new TransactionRequiredException( "no transaction is in progress" ); } //adjustFlushMode(); if ( !contains( entity ) ) throw new IllegalArgumentException( "entity not in the persistence context" ); getSession().lock( entity, getLockMode( lockMode ) ); } catch (HibernateException he) { throwPersistenceException( he ); } }
public RuntimeException convert(RuntimeException e) { RuntimeException result = e; if ( e instanceof HibernateException ) { result = convert( ( HibernateException ) e ); } else { markAsRollback(); } return result; }
public void joinTransaction() { if( !isOpen() ){ throw new IllegalStateException( "EntityManager is closed" ); } joinTransaction( true ); }
public void flush() { try { if ( ! isTransactionInProgress() ) { throw new TransactionRequiredException( "no transaction is in progress" ); } //adjustFlushMode(); getSession().flush(); } catch (HibernateException he) { throwPersistenceException( he ); } }
public void refresh(Object entity, LockModeType lockModeType, Map<String, Object> properties) { checkTransactionNeeded(); CacheMode previousCacheMode = getSession().getCacheMode(); CacheMode localCacheMode = determineAppropriateLocalCacheMode( properties ); LockOptions lockOptions = null; try { getSession().setCacheMode( localCacheMode ); if ( !getSession().contains( entity ) ) { throw new IllegalArgumentException( "Entity not managed" ); } if ( lockModeType != null ) { getSession().refresh( entity, ( lockOptions = getLockRequest( lockModeType, properties ) ) ); } else { getSession().refresh( entity ); } } catch ( MappingException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } catch ( HibernateException he ) { throw convert( he, lockOptions ); } finally { getSession().setCacheMode( previousCacheMode ); } }
public void clear() { try { getSession().clear(); } catch ( HibernateException he ) { throw convert( he ); } }
public void remove(Object entity) { checkTransactionNeeded(); try { getSession().delete( entity ); } catch ( MappingException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } catch ( RuntimeException e ) { //including HibernateException throw convert( e ); } }
public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) { LockOptions lockOptions = null; if ( !isTransactionInProgress() ) { throw new TransactionRequiredException( "no transaction is in progress" ); } try { if ( !contains( entity ) ) { throw new IllegalArgumentException( "entity not in the persistence context" ); } getSession().buildLockRequest( ( lockOptions = getLockRequest( lockModeType, properties ) ) ) .lock( entity ); } catch ( HibernateException he ) { throw convert( he, lockOptions ); } }
/** * returns the underlying session */ public Object getDelegate() { return getSession(); }
public void flush() { try { if ( ! isTransactionInProgress() ) { throw new TransactionRequiredException( "no transaction is in progress" ); } //adjustFlushMode(); getSession().flush(); } catch (HibernateException he) { throwPersistenceException( he ); } }
SQLQuery q = getSession().createSQLQuery( sqlString ); q.setResultSetMapping( resultSetMapping ); return new QueryImpl( q, this ); throwPersistenceException( he ); return null; throwPersistenceException( he ); if ( ! ( e instanceof NoResultException || ( e instanceof NonUniqueResultException ) ) ) { try { markAsRollback(); markAsRollback();
public void throwPersistenceException(HibernateException e) { if ( e instanceof StaleStateException ) { PersistenceException pe = wrapStaleStateException( (StaleStateException) e ); throwPersistenceException( pe ); throwPersistenceException( new EntityNotFoundException( e.getMessage() ) ); throwPersistenceException( new NonUniqueResultException( e.getMessage() ) ); throwPersistenceException( new EntityNotFoundException( e.getMessage() ) ); markAsRollback(); throwPersistenceException( new PersistenceException( e ) );
PersistenceException converted = wrapStaleStateException( ( StaleStateException ) e ); handlePersistenceException( converted ); return converted; PersistenceException converted = wrapLockException( e, lockOptions ); handlePersistenceException( converted ); return converted; PersistenceException converted = wrapLockException( e, lockOptions ); handlePersistenceException( converted ); return converted; handlePersistenceException( converted ); return converted; handlePersistenceException( converted ); return converted; handlePersistenceException( converted ); return converted; handlePersistenceException( converted ); return converted; handlePersistenceException( converted ); return converted; markAsRollback();
public LockModeType getLockMode(Object entity) { if ( !contains( entity ) ) { throw new IllegalArgumentException( "entity not in the persistence context" ); } return getLockModeType( getSession().getCurrentLockMode( entity ) ); }
public void flush() { if ( !isTransactionInProgress() ) { throw new TransactionRequiredException( "no transaction is in progress" ); } try { getSession().flush(); } catch ( RuntimeException e ) { throw convert( e ); } }
private void applyProperties() { getSession().setFlushMode( ConfigurationHelper.getFlushMode( properties.get( AvailableSettings.FLUSH_MODE ) ) ); setLockOptions( this.properties, this.lockOptions ); getSession().setCacheMode( CacheModeHelper.interpretCacheMode( currentCacheStoreMode(), currentCacheRetrieveMode() ) ); }
public void lock(Object entity, LockModeType lockMode) { try { if ( ! isTransactionInProgress() ) { throw new TransactionRequiredException( "no transaction is in progress" ); } //adjustFlushMode(); if ( !contains( entity ) ) throw new IllegalArgumentException( "entity not in the persistence context" ); getSession().lock( entity, getLockMode( lockMode ) ); } catch (HibernateException he) { throwPersistenceException( he ); } }
public Query createQuery(String jpaqlString) { try { return applyProperties( new QueryImpl<Object>( getSession().createQuery( jpaqlString ), this ) ); } catch ( HibernateException he ) { throw convert( he ); } }
protected void postInit() { //register in Sync if needed if ( PersistenceUnitTransactionType.JTA.equals( transactionType ) ) joinTransaction( true ); Object flushMode = properties.get( "org.hibernate.flushMode" ); if (flushMode != null) { getSession().setFlushMode( ConfigurationHelper.getFlushMode( flushMode ) ); } this.properties = null; }