Package org.hibernate

Examples of org.hibernate.Criteria.uniqueResult()


                ProjectionList prolist = Projections.projectionList();
                prolist.add(Projections.rowCount());
                criteria.setProjection(prolist);

                return criteria.uniqueResult();
            }
        });
        return result;
    }
View Full Code Here


                ProjectionList prolist = Projections.projectionList();
                prolist.add(Projections.rowCount());
                criteria.setProjection(prolist);

                return criteria.uniqueResult();
            }
        });
        return result;
    }
View Full Code Here

                Criterion cri0 = Expression.eq("id", id);
                Criterion cri_and = Expression.and(cri0, cri_or);
                criteria.add(cri_and);

                return criteria.uniqueResult();
            }
        });
        return result;
    }
View Full Code Here

                Criterion cri0 = Expression.eq("id", id);
                Criterion cri_and = Expression.and(cri0, cri_or);
                criteria.add(cri_and);

                return criteria.uniqueResult();
            }
        });
        return result;
    }
View Full Code Here

            public Object doInHibernate(Session arg0) throws HibernateException, SQLException {
                Criteria c = arg0.createCriteria(WorkflowDefinition.class);
                c.add(Expression.eq("processId", processId));
                c.add(Expression.eq("version", version));
                return (WorkflowDefinition) c.uniqueResult();
            }
        });
        return workflowDef;
    }
View Full Code Here

                ProjectionList prolist = Projections.projectionList();
                prolist.add(Projections.rowCount());
                criteria.setProjection(prolist);

                return criteria.uniqueResult();
            }
        });
        return result;
    }
View Full Code Here

    // criteria load (forced eager fetch)
    s = openSession();
    t = s.beginTransaction();
    Criteria criteria = s.createCriteria( Group.class );
    criteria.setFetchMode( "users", FetchMode.JOIN );
    hibernate = ( Group ) criteria.uniqueResult();
    assertTrue( Hibernate.isInitialized( hibernate.getUsers() ) );
    assertEquals( 4, hibernate.getUsers().size() );
    assertOrdering( hibernate.getUsers() );
    t.commit();
    s.close();
View Full Code Here

    // criteria load (forced non eager fetch)
    s = openSession();
    t = s.beginTransaction();
    criteria = s.createCriteria( Group.class );
    criteria.setFetchMode( "users", FetchMode.SELECT );
    hibernate = ( Group ) criteria.uniqueResult();
    assertFalse( Hibernate.isInitialized( hibernate.getUsers() ) );
    assertEquals( 4, hibernate.getUsers().size() );
    assertOrdering( hibernate.getUsers() );
    t.commit();
    s.close();
View Full Code Here

  protected abstract class CriteriaExecutor extends QueryExecutor {
    protected abstract Criteria getCriteria(Session s) throws Exception;
    protected Object getResults(Session s, boolean isSingleResult) throws Exception {
      Criteria criteria = getCriteria( s ).setCacheable( getQueryCacheMode() != CacheMode.IGNORE ).setCacheMode( getQueryCacheMode() );
      return ( isSingleResult ? criteria.uniqueResult() : criteria.list() );
    }
  }

  protected abstract class HqlExecutor extends QueryExecutor {
    protected abstract Query getQuery(Session s);
View Full Code Here

    IndexEntry previous = null;
    IndexEntry entry = (IndexEntry) HibernateUtil.getCurrentSession().get(IndexEntry.class, hash);
    while (entry != null && !entry.getCore().equals(core)) {
      previous = entry;
      Criteria fetch = HibernateUtil.getCurrentSession().createCriteria(IndexEntry.class).add(Expression.eq("previousInBucket.coreHash", entry.getCoreHash()));
      entry = (IndexEntry) fetch.uniqueResult();
    }
    if (entry == null) {
      entry = new IndexEntry(core, freeHashSlot(core));
      if (previous != null) {
        entry.setPreviousInBucket(previous);
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.