Package org.hibernate

Examples of org.hibernate.Session.load()


    assertEquals( u.getName(), merged.getName() );
    assertEquals( u.getPassword(), merged.getPassword() );

    merged.setInjectedString( null );

    User loaded = ( User ) s.load(User.class, merged.getName());
    // the session-bound instance was not instantiated by the interceptor, load simply returns it
    assertSame( merged, loaded );
    assertNull( merged.getInjectedString() );

    // flush the session and evict the merged instance from session to force an actual load
View Full Code Here


    // flush the session and evict the merged instance from session to force an actual load
    s.flush();
    s.evict( merged );

    User reloaded = ( User ) s.load( User.class, merged.getName() );
    // Interceptor IS called for instantiating the persistent instance associated to the session when using load
    assertEquals( injectedString, reloaded.getInjectedString() );
    assertEquals( u.getName(), reloaded.getName() );
    assertEquals( u.getPassword(), reloaded.getPassword() );
View Full Code Here

    s = openSession();
    s.beginTransaction();
    // load 'me' to associate it with the new session as a proxy (this may have occurred as 'prior work'
    // to the reattachment below)...
    Object meProxy = s.load( Parent.class, me.getName() );
    assertFalse( Hibernate.isInitialized( meProxy ) );
    // now, do the reattchment...
    s.merge( me );
    s.getTransaction().commit();
    s.close();
View Full Code Here

    s = openSession();
    s.setCacheMode(CacheMode.IGNORE);
    s.beginTransaction();
    s.setDefaultReadOnly( true );
    assertTrue( s.isDefaultReadOnly() );
    dp = ( DataPoint ) s.load( DataPoint.class, new Long( dpId ) );
    s.setDefaultReadOnly( false );
    assertFalse( "was initialized", Hibernate.isInitialized( dp ) );
    assertTrue( s.isReadOnly( dp ) );
    assertFalse( "was initialized during isReadOnly", Hibernate.isInitialized( dp ) );
    dp.setDescription( "changed" );
View Full Code Here

    session.getTransaction().commit();
    session.close();

    session = openSession();
    session.beginTransaction();
        person = (Person) session.load( Person.class, person.getId() );
        person.setName("makingpersondirty");
    session.getTransaction().commit();
    session.close();

    session = openSession();
View Full Code Here

    s.close();
   
    s = openSession();
    t = s.beginTransaction();
    gavin = (User) s.createCriteria(User.class).uniqueResult();
    admins = (Group) s.load(Group.class, "admins");
    plebs = (Group) s.load(Group.class, "plebs");
    banned = (Group) s.load(Group.class, "banned");
    gavin.getGroups().add(admins);
    gavin.getGroups().remove(plebs);
    //gavin.getGroups().add(banned);
View Full Code Here

   
    s = openSession();
    t = s.beginTransaction();
    gavin = (User) s.createCriteria(User.class).uniqueResult();
    admins = (Group) s.load(Group.class, "admins");
    plebs = (Group) s.load(Group.class, "plebs");
    banned = (Group) s.load(Group.class, "banned");
    gavin.getGroups().add(admins);
    gavin.getGroups().remove(plebs);
    //gavin.getGroups().add(banned);
View Full Code Here

    s = openSession();
    t = s.beginTransaction();
    gavin = (User) s.createCriteria(User.class).uniqueResult();
    admins = (Group) s.load(Group.class, "admins");
    plebs = (Group) s.load(Group.class, "plebs");
    banned = (Group) s.load(Group.class, "banned");
    gavin.getGroups().add(admins);
    gavin.getGroups().remove(plebs);
    //gavin.getGroups().add(banned);

    s.delete(plebs);
View Full Code Here

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

    s = openSession();
    s.beginTransaction();
    bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
    assertFalse( Hibernate.isInitialized( bean ) );
    try {
      bean.throwException();
      fail( "exception not thrown" );
    }
View Full Code Here

    dp.setY( new BigDecimal(2.0) );
    s.persist(dp);
    s.flush();
    s.clear();
   
    dp = (DataPoint) s.load(DataPoint.class, new Long( dp.getId() ) );
    assertFalse( Hibernate.isInitialized(dp) );
   
    try {
      dp.getClass().getDeclaredMethod("finalize",null);
      fail();
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.