SharedSessionContract beginTransaction - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SharedSessionContract beginTransaction method.

This code example shows how to use the following methods:beginTransaction
	} 
 
	@Override 
	protected void open() { 
		session = sessionFactory.openSession();
		tx = session.beginTransaction();
	} 
	@SuppressWarnings("unchecked") 
	@Override 
	protected <T> T find(Class<T> entityClass, Serializable id) {
		return (T)session.load(entityClass, id);
	} 
	@Override 
	protected <T> T save(T entity) {
		session.save(entity);
		return entity;
	} 
	@SuppressWarnings("unchecked") 
	@Override 
	protected <T> T merge(T entity) {
8
CodeRank
This code example shows how to use the following methods:beginTransaction
	} 
	 
	@Override 
	protected void open() { 
		session = sessionFactory.openSession();
		tx = session.beginTransaction();
	} 
	@SuppressWarnings("unchecked") 
	@Override 
	protected <T> T find(Class<T> entityClass, Serializable id) {
		return (T)session.load(entityClass, id);
	} 
	@Override 
	protected <T> T save(T entity) {
		session.save(entity);
		return entity;
	} 
	@SuppressWarnings("unchecked") 
	@Override 
	protected <T> T merge(T entity) {
8
CodeRank
This code example shows how to use the following methods:beginTransaction
			session = (Session)m.invoke(sessionFactory);
		}  
		catch (Exception e) {
			throw new RuntimeException("Could not open session", e);
		} 
		tx = session.beginTransaction();
	} 
	@SuppressWarnings("unchecked") 
	protected <T> T find(Class<T> entityClass, Serializable id) {
		Criteria c = session.createCriteria(entityClass);
		c.add(Restrictions.idEq(id));
		return (T)c.uniqueResult();
	} 
	@SuppressWarnings("unchecked") 
	protected <T> T save(T entity) {
		return (T)session.merge(entity);
	} 
	protected <T> void remove(T entity) {
		session.delete(entity);
	} 
8
CodeRank
This code example shows how to use the following methods:beginTransaction
			session = (Session)m.invoke(sessionFactory);
		}  
		catch (Exception e) {
			throw new RuntimeException("Could not open session", e);
		} 
		tx = session.beginTransaction();
	} 
	@SuppressWarnings("unchecked") 
	protected <T> T find(Class<T> entityClass, Serializable id) {
		Criteria c = session.createCriteria(entityClass);
		c.add(Restrictions.idEq(id));
		return (T)c.uniqueResult();
	} 
	@SuppressWarnings("unchecked") 
	protected <T> T save(T entity) {
		return (T)session.merge(entity);
	} 
	protected <T> void remove(T entity) {
		session.delete(entity);
	} 
8
CodeRank
This code example shows how to use the following methods:beginTransaction
    private void begin() { 
        begin(session()); 
    } 
 
    private void begin(Session session) {
        Transaction transaction = session.beginTransaction();
        transaction.begin();
        transactions.push(transaction);
    } 
 
    private void commit() { 
        if (!transactions.isEmpty()) {
            transactions.pop().commit();
        } 
    } 
 
    private void rollback() { 
        if (!transactions.isEmpty()) {
            transactions.pop().rollback();
        } 
8
CodeRank
This code example shows how to use the following methods:close, persist, beginTransaction
		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();
	} 
 
	@Override 
	protected void configure(org.hibernate.cfg.Configuration cfg) {
		super.configure( cfg );
		cfg.setProperty( Environment.ANALYZER_CLASS, StandardAnalyzer.class.getName() );
7
CodeRank
This code example shows how to use the following methods:close, persist, beginTransaction, getTransaction
 
	@Test
	public void testDynamicBoosts() throws Exception {
 
		Session session = openSession();
		session.beginTransaction();
 
		DynamicBoostedDescriptionLibrary lib1 = new DynamicBoostedDescriptionLibrary();
		lib1.setName( "one" );
		session.persist( lib1 );
 
		DynamicBoostedDescriptionLibrary lib2 = new DynamicBoostedDescriptionLibrary();
		lib2.setName( "two" );
		session.persist( lib2 );
 
		session.getTransaction().commit();
		session.close();
 
		float lib1Score = getScore( new TermQuery( new Term( "name", "one" ) ) );
		float lib2Score = getScore( new TermQuery( new Term( "name", "two" ) ) );

7
CodeRank
This code example shows how to use the following methods:close, save, beginTransaction
	} 
 
	private void prepareEntities(String level3Name) {
		Session session = openSession();
		try { 
			Transaction transaction = session.beginTransaction();
 
			Level1 level1 = new Level1();
			DerivedLevel2 level2 = new DerivedLevel2();
			Level3 level3 = new Level3();
 
			level1.setLevel2Child( level2 );
			level2.setLevel1Parent( level1 );
			level2.setLevel3Child( level3 );
			level3.setLevel2Parent( level2 );
 
			level3.setName( level3Name );
 
			session.save( level1 );
			session.save( level2 );

7
CodeRank
This code example shows how to use the following methods:close, flush, save, beginTransaction
 
	private void populateDatabase() { 
		Session session = openSession();
 
		try { 
			Transaction t = session.beginTransaction();
 
			ConcreteEntity entity = new ConcreteEntity();
			session.save( entity );
			entityId = entity.getId();
 
			LazyAbstractEntityReference reference = new LazyAbstractEntityReference( entity );
			session.save( reference );
			entityReferenceId = reference.getId();
 
			session.flush();
			t.commit();
		} 
		finally { 
			session.close();

7
CodeRank
This code example shows how to use the following methods:close, delete, get, beginTransaction
				c.setName( "Palais des festivals" );
				tx.commit();
				s.close();
 
				s = sf.openSession();
				tx = s.beginTransaction();
				w = (Worker) s.get( Worker.class, w.getId() );
				s.delete( w );
				c = (Construction) s.get( Construction.class, c.getId() );
				s.delete( c );
				tx.commit();
				s.close();
			} 
			catch (Throwable t) {
				t.printStackTrace();
			} 
		} 
	} 
 
	@Override 
7
CodeRank
beginTransaction Method Overview
Begin a unit of work and return the associated Transaction object.
See Code Examples for other Hibernate ORM SharedSessionContract Methods: