Package org.hibernate

Examples of org.hibernate.Query.list()


  public List<E> list(final String qname,
      final Object... parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.FIND_SUFFIX));
    this.fittingQuery(query, parameters);
    return query.list();
  }

  /*
   * (non-Javadoc)
   *
 
View Full Code Here


      final Map<String, Object> parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.FIND_SUFFIX));
    this.fittingQuery(query, parameters);
    this.pagingQuery(query, pagination);
    return query.list();
  }

  /*
   * (non-Javadoc)
   *
 
View Full Code Here

      final Pagination pagination, final Object... parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.FIND_SUFFIX));
    this.fittingQuery(query, parameters);
    this.pagingQuery(query, pagination);
    return query.list();
  }

  /*
   * (non-Javadoc)
   *
 
View Full Code Here

    // 处理参数
    this.fittingQuery(query, parameters);

    // 获取查询结果
    final List result = query.list();

    // 返回查询结果
    if (needToPage) {
      Page<E> page = null;
      if (recordAmount == 0) {
View Full Code Here

    public static int count(final org.beangle.model.query.LimitQuery<?> limitQuery,
        final Session hibernateSession) {
      final org.beangle.model.query.Query<?> cntQuery = limitQuery.getCountQuery();
      if (null == cntQuery) {
        Query hibernateQuery = buildHibernateQuery(limitQuery, hibernateSession);
        return hibernateQuery.list().size();
      } else {
        Query hibernateQuery = buildHibernateQuery(cntQuery, hibernateSession);
        final Number count = (Number) (hibernateQuery.uniqueResult());
        if (null == count) {
          return 0;
View Full Code Here

        final Session hibernateSession) {
      if (query instanceof LimitQuery<?>) {
        LimitQuery<T> limitQuery = (LimitQuery<T>) query;
        Query hibernateQuery = buildHibernateQuery(limitQuery, hibernateSession);
        if (null == limitQuery.getLimit()) {
          return hibernateQuery.list();
        } else {
          final PageLimit limit = limitQuery.getLimit();
          hibernateQuery.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize())
              .setMaxResults(limit.getPageSize());
          return hibernateQuery.list();
View Full Code Here

          return hibernateQuery.list();
        } else {
          final PageLimit limit = limitQuery.getLimit();
          hibernateQuery.setFirstResult((limit.getPageNo() - 1) * limit.getPageSize())
              .setMaxResults(limit.getPageSize());
          return hibernateQuery.list();
        }
      } else {
        return buildHibernateQuery(query, hibernateSession).list();
      }
    }
View Full Code Here

      return (T) getHibernateTemplate().get(entityName, id);
    } else {
      String hql = "from " + entityName + " where id =:id";
      Query query = getSession().createQuery(hql);
      query.setParameter("id", id);
      List<?> rs = query.list();
      if (rs.isEmpty()) {
        return null;
      } else {
        return (T) rs.get(0);
      }
View Full Code Here

  @SuppressWarnings("unchecked")
  public <T> List<T> getAll(Class<T> clazz) {
    String hql = "from " + Model.getEntityType(clazz).getEntityName();
    Query query = getSession().createQuery(hql);
    query.setCacheable(true);
    return query.list();
  }

  public <T> List<T> get(Class<T> entityClass, Long... values) {
    return get(entityClass, "id", (Object[]) values);
  }
View Full Code Here

      tx = session.beginTransaction();
      // Query q = session.createQuery("select cat.id from Category as cat");
      // List result = q.list();
      Query q = session.createQuery("from Category as cat where cat.title = :title");
      q.setParameter("title", "Another category title", Hibernate.STRING);
      List cats = q.list();
      tx.commit();
      Iterator it = cats.iterator();
      while (it.hasNext()) {
        Category c = (Category) it.next();
        System.out.println("--> " + c.getId());
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.