Package org.hibernate

Examples of org.hibernate.StatelessSession.beginTransaction()


    ss.insert( paper );
    tx.commit();
    ss.close();

    ss = getSessions().openStatelessSession();
    tx = ss.beginTransaction();
    Paper p2 = ( Paper ) ss.get( Paper.class, paper.getId() );
    p2.setColor( "White" );
    ss.update( p2 );
    tx.commit();
    ss.close();
View Full Code Here


    ss.update( p2 );
    tx.commit();
    ss.close();

    ss = getSessions().openStatelessSession();
    tx = ss.beginTransaction();
    assertEquals( "whtie", paper.getColor() );
    ss.refresh( paper );
    assertEquals( "White", paper.getColor() );
    ss.delete( paper );
    tx.commit();
View Full Code Here

    s.save( task );
    s.getTransaction().commit();
    s.close();

    StatelessSession ss = sfi().openStatelessSession();
    ss.beginTransaction();
    Task taskRef = ( Task ) ss.createQuery( "from Task t join fetch t.resource join fetch t.user" ).uniqueResult();
    assertTrue( taskRef != null );
    assertTrue( Hibernate.isInitialized( taskRef ) );
    assertTrue( Hibernate.isInitialized( taskRef.getUser() ) );
    assertTrue( Hibernate.isInitialized( taskRef.getResource() ) );
View Full Code Here

            final String entityName = event.getEntity().getClass().toString();
            final Date transTime = new Date(); // new Date(event.getSource().getTimestamp());

            // need to have a separate session for audit save
            final StatelessSession session = event.getPersister().getFactory().openStatelessSession();
            session.beginTransaction();
            final String actorId = getActorId(session, event);

            session.insert(new AuditTrail(entityId.toString(), entityName, actorId, transTime));
            session.getTransaction().commit();
        } catch (final HibernateException e) {
View Full Code Here

            final EntityMode entityMode = event.getPersister().guessEntityMode(event.getEntity());
            Object newPropValue = null;

            // need to have a separate session for audit save
            final StatelessSession session = event.getPersister().getFactory().openStatelessSession();
            session.beginTransaction();

            final String actorId = getActorId(session, event);
            for (final String propertyName : event.getPersister().getPropertyNames()) {
                if (!auditColumn.contains(propertyName)) {
                    newPropValue = event.getPersister().getPropertyValue(event.getEntity(), propertyName, entityMode);
View Full Code Here

            Object oldPropValue = null;
            Object newPropValue = null;

            // need to have a separate session for audit save
            final StatelessSession session = event.getPersister().getFactory().openStatelessSession();
            session.beginTransaction();

            // get the existing entity from session so that we can extract existing property values
            final Object existingEntity = session.get(event.getEntity().getClass(), entityId);
            final String actorId = getActorId(session, event);
View Full Code Here

  }

  private void inTransactionWrapper() {
    StatelessSession session = sessionFactory.openStatelessSession();
    try {
      Transaction transaction = session.beginTransaction();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
    }
View Full Code Here

    return new FunctionalTestClassTestSuite( StatelessSessionTest.class );
  }

  public void testCreateUpdateReadDelete() {
    StatelessSession ss = getSessions().openStatelessSession();
    Transaction tx = ss.beginTransaction();
    Document doc = new Document("blah blah blah", "Blahs");
    ss.insert(doc);
    assertNotNull( doc.getName() );
    Date initVersion = doc.getLastModified();
    assertNotNull( initVersion );
View Full Code Here

    assertNotNull( doc.getName() );
    Date initVersion = doc.getLastModified();
    assertNotNull( initVersion );
    tx.commit();
   
    tx = ss.beginTransaction();
    doc.setText("blah blah blah .... blah");
    ss.update(doc);
    assertNotNull( doc.getLastModified() );
    assertNotSame( doc.getLastModified(), initVersion );
    tx.commit();
View Full Code Here

    ss.update(doc);
    assertNotNull( doc.getLastModified() );
    assertNotSame( doc.getLastModified(), initVersion );
    tx.commit();
   
    tx = ss.beginTransaction();
    doc.setText("blah blah blah .... blah blay");
    ss.update(doc);
    tx.commit();
   
    Document doc2 = (Document) ss.get(Document.class.getName(), "Blahs");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.