Package org.hibernate

Examples of org.hibernate.Session.evict()


    s.setReadOnly( dp, true );
    checkReadOnly( s, dp,true );
    dp.setDescription( "changed" );
    assertTrue( Hibernate.isInitialized( dp ) );
    assertEquals( "changed", dp.getDescription() );
    s.evict( dp );
    assertFalse( s.contains( dp ) );
    s.update( dp );
    checkReadOnly( s, dp, false );
    assertEquals( "changed", dp.getDescription() );
    s.flush();
View Full Code Here


    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

    s = openSession();
    s.beginTransaction();
    Parent p = null;
    for (Iterator it = s.createQuery( "from Parent" ).iterate(); it.hasNext(); ) {
      if ( p != null) { s.evict(p); }
      p = (Parent) it.next();
      assertEquals( 1, p.getChildren().size() );
    }
    s.getTransaction().commit();
    s.close();
View Full Code Here

    s = openSession();
    s.beginTransaction();
    for (Iterator it = s.createQuery( "from Parent" ).iterate(); it.hasNext(); ) {
      Parent p = (Parent) it.next();
      assertEquals( 1, p.getChildren().size() );
      s.evict(p);
    }
    s.getTransaction().commit();
    s.close();

    s = openSession();
View Full Code Here

                    entry.getArea().getRootentries().remove(entry.getKey());
                }
            }
            session.delete(_entity);
            _parent.commitHibernateTransaction();
            session.evict(_entity);
        }
        catch (ConstraintViolationException e) {
            throw new WGBackendException("Deletion of document failed because of database constraint violation", e);
        }
        catch (HibernateException e) {
View Full Code Here

        for (final ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY); results.next(); ) {
            final PersistentPortalEvent persistentPortalEvent = (PersistentPortalEvent)results.get(0);
            final PortalEvent portalEvent = this.toPortalEvent(persistentPortalEvent.getEventData(), persistentPortalEvent.getEventType());
            handler.apply(portalEvent);
            persistentPortalEvent.setAggregated(true);
            session.evict(persistentPortalEvent);
        }
    }

    @Override
    @RawEventsTransactional
View Full Code Here

    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

    // persist the record, then evict it, then make changes to it ("within" the session)
    PurchaseRecord record = new PurchaseRecord();
    record.setTimestamp(timestamp1);
    s.persist(record);
    s.flush();
    s.evict(record);
   
    record.setTimestamp(timestamp2);
   
    t.commit();
    s.close();
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.