Package org.hibernate

Examples of org.hibernate.Session.evict()


    s = openSession();
    s.beginTransaction();
    p = ( Parent ) s.get( Parent.class, "p" );
    // evict...
    s.evict( p );
    // now try to reattach...
    s.update( p );
    s.getTransaction().commit();
    s.close();
View Full Code Here


    s = openSession();
    s.beginTransaction();
    p = ( Parent ) s.load( Parent.class, "p" );
    // evict...
    s.evict( p );
    // now try to reattach...
    s.update( p );
    s.getTransaction().commit();
    s.close();
View Full Code Here

        List<DummyEntity> list = new ArrayList<DummyEntity>(count);
        Session session = sf.openSession();
        try {
            for (int i = 0; i < count; i++) {
                DummyEntity e = (DummyEntity) session.get(DummyEntity.class, (long) i);
                session.evict(e);
                list.add(e);
            }
        } finally {
            session.close();
        }
View Full Code Here

        List<DummyEntity> list = new ArrayList<DummyEntity>(count);
        Session session = sf.openSession();
        try {
            for (int i = 0; i < count; i++) {
                DummyEntity e = (DummyEntity) session.get(DummyEntity.class, (long) i);
                session.evict(e);
                list.add(e);
            }
        } finally {
            session.close();
        }
View Full Code Here

        List<DummyEntity> list = new ArrayList<DummyEntity>(count);
        Session session = sf.openSession();
        try {
            for (int i = 0; i < count; i++) {
                DummyEntity e = (DummyEntity) session.get(DummyEntity.class, (long) i);
                session.evict(e);
                list.add(e);
            }
        } finally {
            session.close();
        }
View Full Code Here

        List<DummyEntity> list = new ArrayList<DummyEntity>(count);
        Session session = sf.openSession();
        try {
            for (int i = 0; i < count; i++) {
                DummyEntity e = (DummyEntity) session.get(DummyEntity.class, (long) i);
                session.evict(e);
                list.add(e);
            }
        } finally {
            session.close();
        }
View Full Code Here

    assertTrue( s1.contains( child.getParent() ) );
    assertTrue( Hibernate.isInitialized( child ) );
    assertFalse( Hibernate.isInitialized( child.getChildren() ) );
    assertFalse( Hibernate.isInitialized( child.getParent() ) );
    assertTrue( s1.contains( child ) );
    s1.evict( child );
    assertFalse( s1.contains( child ) );
    assertTrue( s1.contains( child.getParent() ) );

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

    s = openSession();
    t = s.beginTransaction();
    Container c = ( Container ) s.load( Container.class, container.getId() );
    assertFalse( Hibernate.isInitialized( c ) );
    s.evict( c );
    try {
      c.getName();
      fail( "expecting LazyInitializationException" );
    }
    catch( LazyInitializationException e ) {
View Full Code Here

    c = ( Container ) s.load( Container.class, container.getId() );
    assertFalse( Hibernate.isInitialized( c ) );
    Info i = c.getInfo();
    assertTrue( Hibernate.isInitialized( c ) );
    assertFalse( Hibernate.isInitialized( i ) );
    s.evict( c );
    try {
      i.getDetails();
      fail( "expecting LazyInitializationException" );
    }
    catch( LazyInitializationException e ) {
View Full Code Here

    s.clear();

    list = s.createQuery( "from ProductLine" ).list();
    ProductLine pl = ( ProductLine ) list.get( 0 );
    ProductLine pl2 = ( ProductLine ) list.get( 1 );
    s.evict( pl2 );
    pl.getModels().size(); //fetch just one collection! (how can we write an assertion for that??)

    t.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.