Hibernate ORM Transaction - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM Transaction class.

This code example shows how to use the following methods: isActive
 
	@Override 
	public boolean isTransactionInProgress( 
			JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {
 
		return (transaction != null && transaction.isActive()) ||
				TransactionSynchronizationManager.isActualTransactionActive(); 
	} 
 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
			cars[i] = new LegacyCar();
			cars[i].setId( "" + i );
			cars[i].setModel( "model" + i );
			fullTextSession.persist( cars[i] );
		} 
		transaction.commit();
	} 
 
	@Override 
	protected Class<?>[] getAnnotatedClasses() {
		return new Class[] { LegacyCarPlant.class, LegacyCar.class, LegacyTire.class };
	} 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit, isActive
	@Override 
	@After 
	public void tearDown() throws Exception {
		try { 
			Transaction tx = fts.getTransaction();
			if ( !tx.isActive() ) {
				tx = fts.beginTransaction();
			} 
			assertEquals( 1000, fts.createQuery( "delete from " + Clock.class.getName() ).executeUpdate() );
			fts.purgeAll( Clock.class );
			tx.commit();
			fts.close();
		} 
		finally { 
			super.tearDown(); 
		} 
	} 
 
	@Test
	public void testTimeout() { 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
		// verify the deletion 
		session = CloudSessionFactory.getInstance().openSession();
		try { 
			Transaction txn = session.beginTransaction();
			bucket = (SBucket)session.get(SBucket.class, bucketId);
			txn.commit();
			 
			Assert.assertTrue(bucket == null);
		} finally { 
			session.close();
		} 
    } 
     
    public void testSObject() { 
    	SHost host;
    	SBucket bucket;
    	Session session;
    	SObject sobject;
    	 
    	// setup  
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
			FullTextSession session = fullTextSessionBuilder.openFullTextSession();
			Assert.assertEquals( 0, LeakingOptimizer.getTotalOperations() );
 
			Transaction tx = session.beginTransaction();
			session.persist( new Document( "The Book", "many paper pages assembled together at one side", "[old language you don't understand]" ) );
			tx.commit();
 
			Assert.assertEquals( 1, LeakingOptimizer.getTotalOperations() );
			Assert.assertEquals( 1, LeakingLuceneBackend.getLastProcessedQueue().size() );
 
			tx = session.beginTransaction();
			List list = session.createFullTextQuery( new MatchAllDocsQuery() ).list();
			Document doc = (Document) list.get( 0 );
			doc.setSummary( "Example of what was used in ancient times to read" ); 
			tx.commit();
 
			Assert.assertEquals( 1, LeakingLuceneBackend.getLastProcessedQueue().size() );
			Assert.assertEquals( expectedBackendOperations, LeakingOptimizer.getTotalOperations() );
		} 
		finally { 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: rollback, wasCommitted, wasRolledBack
        }else{ 
            tx = (Transaction)threadTransaction.get();
            threadTransaction.set(null);
        } 
		try { 
			if ( tx != null && !tx.wasCommitted() && !tx.wasRolledBack() ) {
				tx.rollback();
			} 
		} catch (HibernateException e) {
			logger.error("Exception " + e.getMessage(), e);
			throw new PersistException(e);
		} finally { 
			closeSession(cloudStackTxn);
		} 
	} 
	 
	public static void rollbackTransaction() { 
	    rollbackTransaction(false); 
	} 
	 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
		assertTrue( suspectQuery.list().get( 0 ) instanceof Suspect );
 
		assertEquals( 2, fts.createFullTextQuery( q ).getResultSize() );
		assertEquals( 2, fts.createFullTextQuery( q, Detective.class, Suspect.class ).getResultSize() );
 
		tx.commit();
		fts.close();
	} 
 
	private void createDoeFamily() { 
		Session s = openSession( );
		Transaction tx = s.beginTransaction();
		Detective detective = new Detective();
		detective.setName( "John Doe" );
		s.persist( detective );
		Suspect suspect = new Suspect();
		suspect.setName( "Jane Doe" );
		s.persist( suspect );
		tx.commit();
		s.close();
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
			FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( q );
			assertEquals( 1, fullTextQuery.getResultSize() );
 
			Level3 level3 = (Level3) fullTextQuery.list().get( 0 );
			level3.setName( newName );
			transaction.commit();
		} 
		finally { 
			fullTextSession.close();
		} 
	} 
 
	@Override 
	protected Class<?>[] getAnnotatedClasses() {
		return new Class[] { Level1.class, Level2.class, DerivedLevel2.class, Level3.class };
	} 
 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
			assertEquals( 1, resultSize );
 
			@SuppressWarnings("unchecked") 
			List<Root> list = fullTextQuery.list();
			assertEquals( 1, list.size() );
			transaction.commit();
		} 
		finally { 
			fullTextSession.close();
		} 
	} 
 
	private void prepareEntities() { 
		Session session = openSession();
		try { 
			Transaction transaction = session.beginTransaction();
 
			LazyItem bridgedEntity = new LazyItem();
			session.save( bridgedEntity );
 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: commit
 
	private void addToCollectionAndPersist(EntityExtendingMappedSuperclassWithCollectionField entity, String value) {
		Transaction transaction = fullTextSession.beginTransaction();
		entity.getCollection().add( value );
		fullTextSession.persist( entity );
		transaction.commit();
		fullTextSession.clear();
	} 
 
	@SuppressWarnings("unchecked") 
	private List<EntityExtendingMappedSuperclassWithCollectionField> searchEntityByCollectionValue(String value) {
		FullTextQuery query = fullTextSession.createFullTextQuery(
				new TermQuery( new Term( "collection", value ) ),
				EntityExtendingMappedSuperclassWithCollectionField.class 
		); 
		return query.list();
	} 
 
	@Override 
	protected Class<?>[] getAnnotatedClasses() {
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Hibernate ORM Transaction Methods: