Package org.hibernate

Examples of org.hibernate.Session.refresh()


    assertTrue( Hibernate.isInitialized( dp ) );
    dp.setDescription( "changed" );
    assertEquals( "changed", dp.getDescription() );
    assertTrue( s.isReadOnly( dp ) );
    assertTrue( s.isReadOnly( ( ( HibernateProxy ) dp ).getHibernateLazyInitializer().getImplementation() ) );
    s.refresh( dp );
    assertEquals( "original", dp.getDescription() );
    dp.setDescription( "changed" );
    assertEquals( "changed", dp.getDescription() );
    assertTrue( s.isReadOnly( dp ) );
    assertTrue( s.isReadOnly( ( ( HibernateProxy ) dp ).getHibernateLazyInitializer().getImplementation() ) );
View Full Code Here


    t = s.beginTransaction();
    dp = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
    s.delete( dp );
    s.flush();
    try {
      s.refresh( dp );
      fail( "should have thrown UnresolvableObjectException" );
    }
    catch ( UnresolvableObjectException ex ) {
      // expected
    }
View Full Code Here

    s = openSession();
    t = s.beginTransaction();
    assertTrue( dpProxyInit instanceof HibernateProxy );
    assertTrue( Hibernate.isInitialized( dpProxyInit ) );
    try {
      s.refresh( dpProxyInit );
      fail( "should have thrown UnresolvableObjectException" );
    }
    catch ( UnresolvableObjectException ex ) {
      // expected
    }
View Full Code Here

    s = openSession();
    t = s.beginTransaction();
    assertTrue( dpProxy instanceof HibernateProxy );
    try {
      s.refresh( dpProxy );
      assertFalse( Hibernate.isInitialized( dpProxy ) );
      Hibernate.initialize( dpProxy );
      fail( "should have thrown UnresolvableObjectException" );
    }
    catch ( UnresolvableObjectException ex ) {
View Full Code Here

    assertFalse( Hibernate.isInitialized( dp ) );
    assertFalse( s.isReadOnly( dp ) );
    s.setReadOnly( dp, true );
    assertTrue( s.isReadOnly( dp ) );
    s.evict( dp );
    s.refresh( dp );
    assertFalse( Hibernate.isInitialized( dp ) );
    assertFalse( s.isReadOnly( dp ) );
    dp.setDescription( "changed" );
    assertEquals( "changed", dp.getDescription() );
    assertTrue( Hibernate.isInitialized( dp ) );
View Full Code Here

    dp.setDescription( "changed" );
    assertEquals( "changed", dp.getDescription() );
    assertTrue( Hibernate.isInitialized( dp ) );
    s.setReadOnly( dp, true );
    s.evict( dp );
    s.refresh( dp );
    assertEquals( "original", dp.getDescription() );
    assertFalse( s.isReadOnly( dp ) );
    t.commit();

    s.clear();
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) {
         log.error("rolling back", e);
View Full Code Here

    checkReadOnly( s, dp, false );

    s.beginTransaction();
    checkReadOnly( s, dp, false );
    assertEquals( "changed", dp.getDescription() );
    s.refresh( dp );
    assertEquals( dpOrig.getDescription(), dp.getDescription() );
    checkReadOnly( s, dp, false );
    dp.setDescription( "changed again" );
    assertEquals( "changed again", dp.getDescription() );
    s.flush();
View Full Code Here

    s.beginTransaction();
    node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
    // the changed name is still in the session
    assertEquals( "node-name", node.getName() );
    s.refresh( node );
    // after refresh, the name reverts to the original value
    assertEquals( "node", node.getName() );
    node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
    assertEquals( "node", node.getName() );
    s.getTransaction().commit();
View Full Code Here

    assertEquals( "node", node.getName() );
    s.setReadOnly( node, true );
    node.setName( "diff-node-name" );
    s.flush();
    assertEquals( "diff-node-name", node.getName() );
    s.refresh( node );
    assertEquals( "node", node.getName() );
    s.setReadOnly( node, false );
    node.setName( "diff-node-name" );
    s.getTransaction().commit();
    s.close();
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.