Package org.hibernate

Examples of org.hibernate.Query.list()


      return false;
    type = metadataUtil.getUnproxiedClass(type); //Get the real entity class

    Query query = getSession().createQuery("select id from " + getMetadataUtil().get(type).getEntityName() + " where id = :id");
    query.setParameter("id", id);
    return query.list().size() == 1;
  }

  protected boolean[] _exists(Class<?> type, Serializable... ids) {
    if (type == null)
      throw new NullPointerException("Type is null.");
View Full Code Here


    Query query = getSession().createQuery(sb.toString());
    for (int i = 0; i < ids.length; i++) {
      query.setParameter("id" + i, ids[i]);
    }

    for (Serializable id : (List<Serializable>) query.list()) {
      for (int i = 0; i < ids.length; i++) {
        if (id.equals(ids[i])) {
          ret[i] = true;
          // don't break. the same id could be in the list twice.
        }
View Full Code Here

    Query query = session.createQuery(hql);
    addParams(query, paramList);
    addPaging(query, search);
    addResultMode(query, search);

    return query.list();
  }

  /**
   * Returns the total number of results that would be returned using the
   * given <code>ISearch</code> if there were no paging or maxResult limits.
View Full Code Here

        if (id != null) {
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    Query query = session.createQuery("from " + ClusterNode.class.getName() +"  cn  where cn.id = :idToSearch");
                    query.setLong("idToSearch", id);
                    List queryResult = query.list();

                    if (queryResult.size() > 1) log.error("There is more than one cluster node resgistered for identifier " + id + ".!!!");
                    if (!queryResult.isEmpty()) result[0] = (ClusterNode) queryResult.get(0);
                }
            }.execute();
View Full Code Here

        if (ip != null) {
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    Query query = session.createQuery("from " + ClusterNode.class.getName() +"  cn  where cn.nodeAddress = :ipToSearch");
                    query.setString("ipToSearch", ip);
                    List queryResult = query.list();

                    if (queryResult.size() > 1) log.error("There is more than one cluster node resgistered for IP address: " + ip + ".");
                    if (!queryResult.isEmpty()) result[0] = (ClusterNode) queryResult.get(0);
                }
            }.execute();
View Full Code Here

            protected void txFragment(Session session) throws Exception {
                Query query = session.createQuery(" from " + DataSourceEntry.class.getName());
                FlushMode oldFlushMode = session.getFlushMode();
                session.setFlushMode(FlushMode.COMMIT);
                query.setCacheable(true);
                result.addAll(query.list());
                session.setFlushMode(oldFlushMode);
            }}.execute();
        } catch (Exception e) {
            log.error("Error: ", e);
        }
View Full Code Here

            sql.append("where dse.name = :name");

            Query query = session.createQuery(sql.toString());
            query.setString("name", name);
            query.setCacheable(true);
            results.addAll(query.list());
            session.setFlushMode(flushMode);
        }}.execute();
        if (results.size() > 0) {
            if (results.size() > 1) log.error("There are " + results.size() + " data sources with name=" + name);
            return (DataSourceEntry)results.get(0);
View Full Code Here

        if (status != null) {
            new HibernateTxFragment() {
                protected void txFragment(Session session) throws Exception {
                    Query query = session.createQuery("from " + ClusterNode.class.getName() +" cn  where cn.nodeStatus = :nStatus");
                    query.setString("nStatus", status.name());
                    List queryResult = query.list();

                    if (queryResult != null && !queryResult.isEmpty()) {
                        for (Object obj : queryResult) {
                            result.add((ClusterNode) obj);
                        }
View Full Code Here

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { author:'Oscar Wilde' } ) RETURN n ORDER BY n.name";
    Query query = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.class )
        .setFirstResult( 1 );
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = query.list();

    assertThat( result ).containsExactly( ballade, portia );

    transaction.commit();
    session.clear();
View Full Code Here

    String nativeQuery = "MATCH ( n:" + TABLE_NAME + " { author:'Oscar Wilde' } ) RETURN n ORDER BY n.name";
    Query query = session.createNativeQuery( nativeQuery )
        .addEntity( OscarWildePoem.class )
        .setMaxResults( 2 );
    @SuppressWarnings("unchecked")
    List<OscarWildePoem> result = query.list();

    assertThat( result ).containsExactly( athanasia, ballade );

    transaction.commit();
    session.clear();
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.