Package org.hibernate

Examples of org.hibernate.Query


    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<bookmarkIds.length;i++){
        String s_id = (String)bookmarkIds[i];
        int id = -1;
        try{
          id = Integer.parseInt(s_id);
        }catch(Exception e){}
        q.setInteger(i+1, id);
      }
      q.setInteger(i+1, -1);
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here


  protected final static Log log = LogFactory.getLog(FindAction.class);

  @SuppressWarnings("unchecked")
  @Override
  public Object execute(Object[] parameters) {
    Query query = getQuery();
    QueryParameters queryPara = new QueryParameters(parameters, method.getParameterAnnotations());
    fittingQuery(query, queryPara);
    Find find = getAnnotation();
    if (!find.resultClass().equals(void.class))
      return toProjectionalList(find.resultClass(), query.list());
    return query.list();
  }
View Full Code Here

   * org.jrest4guice.persistence.jpa.BaseEntityManager#countByNamedQuery(java
   * .lang.String, java.util.Map)
   */
  public long count(final String qname,
      final Map<String, Object> parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.COUNT_SUFFIX));
    this.fittingQuery(query, parameters);
    final Object result = query.uniqueResult();
    if (result instanceof BigInteger) {
      return ((BigInteger) result).longValue();
    } else {
      return ((Long) result).longValue();
    }
View Full Code Here

   * org.jrest4guice.persistence.jpa.BaseEntityManager#countByNamedQuery(java
   * .lang.String, java.lang.Object)
   */
  public long count(final String qname,
      final Object... parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.COUNT_SUFFIX));
    this.fittingQuery(query, parameters);
    final Object result = query.uniqueResult();
    if (result instanceof BigInteger) {
      return ((BigInteger) result).longValue();
    } else {
      return ((Long) result).longValue();
    }
View Full Code Here

   * org.jrest4guice.persistence.jpa.BaseEntityManager#listByNamedQuery(java
   * .lang.String, java.util.Map)
   */
  public List<E> list(final String qname,
      final Map<String, Object> parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.FIND_SUFFIX));
    this.fittingQuery(query, parameters);
    return query.list();
  }
View Full Code Here

   * org.jrest4guice.persistence.jpa.BaseEntityManager#listByNamedQuery(java
   * .lang.String, java.lang.Object)
   */
  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();
  }
View Full Code Here

   * .lang.String, org.jrest4guice.client.Pagination, java.util.Map)
   */
  public List<E> list(final String qname,
      final Pagination pagination,
      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();
  }
View Full Code Here

   * org.jrest4guice.persistence.jpa.BaseEntityManager#listByNamedQuery(java
   * .lang.String, org.jrest4guice.client.Pagination, java.lang.Object)
   */
  public List<E> list(final String qname,
      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();
  }
View Full Code Here

   * org.jrest4guice.persistence.jpa.BaseEntityManager#loadByNamedQuery(java
   * .lang.String, java.util.Map)
   */
  public E load(final String qname,
      final Map<String, Object> parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.LOAD_SUFFIX));
    this.fittingQuery(query, parameters);
    try {
      return (E) query.uniqueResult();
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

   * @see
   * org.jrest4guice.persistence.jpa.BaseEntityManager#loadByNamedQuery(java
   * .lang.String, java.lang.Object)
   */
  public E load(final String qname, final Object... parameters) {
    final Query query = this.createQuery(this.getFullQueryName(qname,
        BaseEntityManager.LOAD_SUFFIX));
    this.fittingQuery(query, parameters);
    try {
      return (E) query.uniqueResult();
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.Query

Copyright © 2018 www.massapicom. 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.