Java Code Examples for org.hibernate.Transaction#getStatus()
The following examples show how to use
org.hibernate.Transaction#getStatus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheHibernateStoreSessionListener.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) { Session hibSes = ses.attach(null); if (hibSes != null) { try { Transaction tx = hibSes.getTransaction(); if (commit) { if (hibSes.isDirty()) hibSes.flush(); if (tx.getStatus() == TransactionStatus.ACTIVE) tx.commit(); } else if (tx.getStatus().canRollback()) tx.rollback(); } catch (HibernateException e) { throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e); } finally { hibSes.close(); } } }
Example 2
Source File: CacheHibernateBlobStoreSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); Session s = store.session(null); if (s == null) return; try { s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName()) .setFlushMode(FlushMode.ALWAYS).executeUpdate(); Transaction hTx = s.getTransaction(); if (hTx != null && hTx.getStatus() == TransactionStatus.ACTIVE) hTx.commit(); } finally { s.close(); } }
Example 3
Source File: CacheHibernateStoreSessionListener.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) { Session hibSes = ses.attach(null); if (hibSes != null) { try { Transaction tx = hibSes.getTransaction(); if (commit) { if (hibSes.isDirty()) hibSes.flush(); if (tx.getStatus() == TransactionStatus.ACTIVE) tx.commit(); } else if (tx.getStatus().canRollback()) tx.rollback(); } catch (HibernateException e) { throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e); } finally { hibSes.close(); } } }
Example 4
Source File: CacheHibernateBlobStoreSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); Session s = store.session(null); if (s == null) return; try { s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName()) .setFlushMode(FlushMode.ALWAYS).executeUpdate(); Transaction hTx = s.getTransaction(); if (hTx != null && hTx.getStatus() == TransactionStatus.ACTIVE) hTx.commit(); } finally { s.close(); } }