Package org.hibernate

Examples of org.hibernate.Session.load()


    boolean hasOpen = HibernateUtilOld.hasOpenSession();
    Session sess = Helper.getHibernateSession();

    Schritt current = (Schritt) sess.get(Schritt.class, this.getId());
    if (current == null) {
      current = (Schritt) sess.load(Schritt.class, this.getId());
    }
    if (!hasOpen) {
      current.eigenschaften.size();
      current.benutzer.size();
      current.benutzergruppen.size();
View Full Code Here


      withTx(tm, new Callable<Void>() {
         @Override
         public Void call() throws Exception {
            Session s = openSession();
            Item loaded = (Item) s.load( Item.class, item.getId() );
            assertEquals( 1, loaded.getItems().size() );
            s.close();
            return null;
         }
      });
View Full Code Here

         @Override
         public Void call() throws Exception {
            Session s = openSession();
            s.getTransaction().begin();
            SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" );
            Item loadedWithCachedCollection = (Item) s.load( Item.class, item.getId() );
            stats.logSummary();
            assertEquals( item.getName(), loadedWithCachedCollection.getName() );
            assertEquals( item.getItems().size(), loadedWithCachedCollection.getItems().size() );
            assertEquals( 1, cStats.getHitCount() );
            Map cacheEntries = cStats.getEntries();
View Full Code Here

    beginTx();
    try {
      // cleanup
      s = openSession();
      txn = s.beginTransaction();
      item = (VersionedItem) s.load( VersionedItem.class, item.getId() );
      s.delete( item );
      txn.commit();
      s.close();
    }
    catch (Exception e) {
View Full Code Here

        Person aPerson = (Person) session
                .createQuery("select p from Person p left join fetch p.events where p.id = :pid")
                .setParameter("pid", personId)
                .uniqueResult(); // Eager fetch the collection so we can use it detached

        Event anEvent = (Event) session.load(Event.class, eventId);
        // If we want to handle it bidirectional and detached, we also need to load this
        // collection with an eager outer-join fetch, this time with Criteria and not HQL:
        /*
        Event anEvent = (Event) session
                .createCriteria(Event.class).setFetchMode("participants", FetchMode.JOIN)
View Full Code Here

    private void addEmailToPerson(Long personId, String emailAddress) {

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        Person aPerson = ( Person ) session.load(Person.class, personId);

        // The getEmailAddresses() might trigger a lazy load of the collection
        aPerson.getEmailAddresses().add(emailAddress);

        session.getTransaction().commit();
View Full Code Here

        }

        // cleanup
        s = openSession();
        txn = s.beginTransaction();
        item = (VersionedItem) s.load(VersionedItem.class, item.getId());
        s.delete(item);
        txn.commit();
        s.close();

    }
View Full Code Here

    }
   
    private void updateProcessLog(long processInstanceId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        ProcessInstanceLog log = (ProcessInstanceLog) session.load(ProcessInstanceLog.class, processInstanceId);
        log.setEnd(new Date());
        session.update(log);
        session.getTransaction().commit();
    }
   
View Full Code Here

    Session session = openSession();
    session.enableFilter( "seniorSalespersons" )
            .setParameter( "asOfDate", testData.lastMonth.getTime() );

    Department department = ( Department ) session.load( Department.class, testData.deptId );
    Set salespersons = department.getSalespersons();
    assertEquals( "Incorrect salesperson count", 1, salespersons.size() );

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

    Session session = openSession();
    long ts = ( ( SessionImplementor ) session ).getTimestamp();

    // Force a collection into the second level cache, with its non-filtered elements
    Salesperson sp = ( Salesperson ) session.load( Salesperson.class, testData.steveId );
    Hibernate.initialize( sp.getOrders() );
    CollectionPersister persister = ( ( SessionFactoryImpl ) getSessions() )
            .getCollectionPersister( Salesperson.class.getName() + ".orders" );
    assertTrue( "No cache for collection", persister.hasCache() );
    CollectionCacheEntry cachedData = ( CollectionCacheEntry ) persister.getCache().getCache()
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.