Package org.hibernate

Examples of org.hibernate.Session.refresh()


    assertSame( cOrig, c );
    checkContainer( c, expectedInitializedObjects, expectedReadOnlyObjects, s );
    c = ( Container ) s.get( Container.class, cOrig.getId() );
    assertSame( cOrig, c );
    checkContainer( cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s );
    s.refresh( cOrig );
    assertSame( cOrig, c );
    checkContainer( cOrig, expectedInitializedObjects, expectedReadOnlyObjects, s );
    s.evict( cOrig );
    c = ( Container ) s.get( Container.class, cOrig.getId()  );
    assertNotSame( cOrig, c );
View Full Code Here


    Session s = openSession();
    s.beginTransaction();
    CacheableItem item = new CacheableItem( "data" );
    s.save( item );
    s.flush();
    s.refresh( item );
    s.getTransaction().commit();
    s.close();

    Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
    assertEquals( 1, cacheMap.size() );
View Full Code Here

    Session s = openSession();
    s.beginTransaction();
    CacheableItem item = new CacheableItem( "data" );
    s.save( item );
    s.flush();
    s.refresh( item );
    s.getTransaction().rollback();
    s.close();

    Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
    assertEquals( 0, cacheMap.size() );
View Full Code Here

    clearCounts();

    s = openSession();
    t = s.beginTransaction();
    // refresh detached
    s.refresh( c );
    assertTrue( s.isReadOnly( c ) );
    assertEquals( c.getCustomerName(), "gavin" );
    assertEquals( c.getVariations().size(), 2 );
    Iterator it = c.getVariations().iterator();
    cv1 = (ContractVariation) it.next();
View Full Code Here

    c.setCustomerName( "joe" );

    s = openSession();
    t = s.beginTransaction();
    // refresh updated detached
    s.refresh( c );
    assertTrue( s.isReadOnly( c ) );
    assertEquals( c.getCustomerName(), "gavin" );
    assertEquals( c.getVariations().size(), 2 );
    it = c.getVariations().iterator();
    cv1 = (ContractVariation) it.next();
View Full Code Here

    // behind the session's back, let's modify the statuses
    updateStatuses( session.connection() );

    // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
    session.refresh( batch );

    Iterator itr = batch.getJobs().iterator();
    while( itr.hasNext() ) {
      Job job = ( Job ) itr.next();
      assertEquals( "Jobs not refreshed!", 1, job.getStatus() );
View Full Code Here

    Person e = new Person( FIRST_NAME, LAST_NAME );
    s.persist( e );
    MedicalHistory d = new MedicalHistory( e );
    s.persist( d );
    s.flush();
    s.refresh( d );
    s.getTransaction().commit();
    s.close();

    s = openSession();
    s.getTransaction().begin();
View Full Code Here

    Person e = new Person( FIRST_NAME, LAST_NAME );
    s.persist( e );
    MedicalHistory d = new MedicalHistory( e );
    s.persist( d );
    s.flush();
    s.refresh( d );
    s.getTransaction().commit();

    // NOTE THAT WE LEAVE THE SESSION OPEN!

    s.getTransaction().begin();
View Full Code Here

      log.debug("Getting account " + id + " with refresh");
      tm.begin();
      try {
          Session session = sessionFactory.getCurrentSession();
          Account acct  = (Account) session.get(acctClass, id);
          session.refresh(acct);
          acct = (Account) session.get(acctClass, id);
          tm.commit();
          return acct;
      }
      catch (Exception e) {
View Full Code Here

    s.setCacheMode(CacheMode.IGNORE);
    t = s.beginTransaction();
    dp = ( DataPoint ) s.load( DataPoint.class, dp.getId() );
    s.setReadOnly( dp, true );
    assertFalse( Hibernate.isInitialized( dp ) );
    s.refresh( dp );
    assertFalse( Hibernate.isInitialized( dp ) );
    assertEquals( "original", dp.getDescription() );
    assertTrue( Hibernate.isInitialized( dp ) );
    dp.setDescription( "changed" );
    assertEquals( "changed", dp.getDescription() );
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.