Package org.hibernate

Examples of org.hibernate.Session.load()


    session.close();

    session = openSession();
    session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
    sp = ( Salesperson ) session.load( Salesperson.class, testData.steveId );
    assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrders().size() );

    session.close();

    // Finally, make sure that the original cached version did not get over-written
View Full Code Here


    session.close();

    // Finally, make sure that the original cached version did not get over-written
    session = openSession();
    sp = ( Salesperson ) session.load( Salesperson.class, testData.steveId );
    assertEquals( "Actual cached version got over-written", 2, sp.getOrders().size() );

    session.close();
    testData.release();
  }
View Full Code Here

    plat.setBodyWeight( 11f );
    plat.setDescription( "Platypus" );
    s.persist( plat );
    s.flush();
    s.clear();
    plat = (Mammal) s.load(Mammal.class, plat.getId() );
    assertFalse( Hibernate.isInitialized(plat) );
    Object plat2 = s.createQuery("from Animal a").uniqueResult();
    assertSame(plat, plat2);
    assertTrue( Hibernate.isInitialized(plat) );
    s.delete(plat);
View Full Code Here

    s.createQuery( "from PropertySet p where p.someSpecificProperty.id is not null" ).list();

    s.createQuery( "from PropertySet p join p.generalProperties gp where gp.id is not null" ).list();

    s.delete( s.load( PropertySet.class, id ) );

    s.getTransaction().commit();
    s.close();
  }
View Full Code Here

  private void destroyTestBaseData() {
    Session session = openSession();
    Transaction txn = session.beginTransaction();

    for ( int i = 0; i < createdAnimalIds.size(); i++ ) {
      Animal animal = ( Animal ) session.load( Animal.class, ( Long ) createdAnimalIds.get( i ) );
      session.delete( animal );
    }

    txn.commit();
    session.close();
View Full Code Here

  {
    Session session = openSession();
   
    try
    {     
      Object object = session.load(classType, id);
      return object;
    }
    catch (HibernateException he)
    {     
      throw new ProviderException(he);
View Full Code Here

         
      ApplicationContext appContext = new ClassPathXmlApplicationContext(defaultConfigPaths);
      ObjectDAO objectDAO = (ObjectDAO)appContext.getBean("objectDAO");
      Session session = objectDAO.getHibSession();
            Transaction tx = session.beginTransaction();
              AccountDO accountsDO = (AccountDO)session.load(AccountDO.class, 2);
             
            tx.commit();
            session.close();
            //accountsDO.setAccountId(2);
           session = objectDAO.getHibSession();
View Full Code Here

                         try {
                          
                           ObjectDAO objectDAO = (ObjectDAO)fappContext.getBean("objectDAO");
                           Session session = objectDAO.getHibSession();
                           Transaction tx = session.beginTransaction();
                             AccountDO accountsDO = (AccountDO)session.load(AccountDO.class, 2);
                           tx.commit();
                           //accountsDO.setAccountId(2);
                           accountsDO.setName("gfeabcaaaaad");
                           accountsDO.setLoginName("gfeaaaaaaa");
                           session.merge(accountsDO);
View Full Code Here

    assertNotNull( "customer id not assigned", customer.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

    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    f = (Forest) s.load( Forest.class, f.getId() );
    t = (Tree) s.load( Tree.class, t.getId() );
    assertFalse( "Default should be lazy", Hibernate.isInitialized( f ) );
    assertTrue( "Tree is not lazy", Hibernate.isInitialized( t ) );
    tx.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.