Package org.hibernate

Examples of org.hibernate.Session.load()


    txn.commit();
    session.close();

    session = openSession();
    txn = session.beginTransaction();
    user = ( User ) session.load( User.class, user.getId() );
    session.delete( user );
    txn.commit();
    session.close();

    session = openSession();
View Full Code Here


    assertNotNull( "wife:Person id not assigned", wife.getId() );

    // Test loading these dyna-proxies, along with flush processing
    session = openSession();
    session.beginTransaction();
    customer = ( Customer ) session.load( Customer.class, customer.getId() );
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer ) );

    customer.setName( "other" );
    session.flush();
    assertFalse( "should-be-proxy was initialized", Hibernate.isInitialized( customer.getCompany() ) );
View Full Code Here

    t = s.beginTransaction();
   
    a = new Address();
    a.setType("HOME");
    a.setPerson(p);
    a = (Address) s.load(Address.class, a);
    assertFalse( Hibernate.isInitialized(a) );
    a.getPerson();
    a.getType();
    assertFalse( Hibernate.isInitialized(a) );
    assertEquals(a.getZip(), "3181");
View Full Code Here

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

    s = openSession();
    s.beginTransaction();
    me = ( Person ) s.load( Person.class, me.name );
    assertNull( me.address );
    s.delete( me );
    s.getTransaction().commit();
    s.close();
  }
View Full Code Here

    Long aid = a.getId();
    Long bid = b.getId();

    s = openSession();
    t = s.beginTransaction();
    b = ( Bid ) s.load( Bid.class, bid );
    assertFalse( Hibernate.isInitialized( b ) );
    a = ( Auction ) s.get( Auction.class, aid );
    assertFalse( Hibernate.isInitialized( a.getBids() ) );
    assertFalse( Hibernate.isInitialized( a.getSuccessfulBid() ) );
    assertSame( a.getBids().iterator().next(), b );
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    b = ( Bid ) s.load( Bid.class, bid );
    assertFalse( Hibernate.isInitialized( b ) );
    a = ( Auction ) s.createQuery( "from Auction a left join fetch a.bids" ).uniqueResult();
    assertTrue( Hibernate.isInitialized( b ) );
    assertTrue( Hibernate.isInitialized( a.getBids() ) );
    assertSame( b, a.getSuccessfulBid() );
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    b = ( Bid ) s.load( Bid.class, bid );
    a = ( Auction ) s.load( Auction.class, aid );
    assertFalse( Hibernate.isInitialized( b ) );
    assertFalse( Hibernate.isInitialized( a ) );
    s.createQuery( "from Auction a left join fetch a.successfulBid" ).list();
    assertTrue( Hibernate.isInitialized( b ) );
View Full Code Here

    s.close();

    s = openSession();
    t = s.beginTransaction();
    b = ( Bid ) s.load( Bid.class, bid );
    a = ( Auction ) s.load( Auction.class, aid );
    assertFalse( Hibernate.isInitialized( b ) );
    assertFalse( Hibernate.isInitialized( a ) );
    s.createQuery( "from Auction a left join fetch a.successfulBid" ).list();
    assertTrue( Hibernate.isInitialized( b ) );
    assertTrue( Hibernate.isInitialized( a ) );
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    b = ( Bid ) s.load( Bid.class, bid );
    a = ( Auction ) s.load( Auction.class, aid );
    assertFalse( Hibernate.isInitialized( b ) );
    assertFalse( Hibernate.isInitialized( a ) );
    assertSame( s.get( Bid.class, bid ), b );
    assertTrue( Hibernate.isInitialized( b ) );
View Full Code Here

    s.close();

    s = openSession();
    t = s.beginTransaction();
    b = ( Bid ) s.load( Bid.class, bid );
    a = ( Auction ) s.load( Auction.class, aid );
    assertFalse( Hibernate.isInitialized( b ) );
    assertFalse( Hibernate.isInitialized( a ) );
    assertSame( s.get( Bid.class, bid ), b );
    assertTrue( Hibernate.isInitialized( b ) );
    assertSame( s.get( Auction.class, aid ), a );
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.