Example usage for org.hibernate SQLQuery setInteger

List of usage examples for org.hibernate SQLQuery setInteger

Introduction

In this page you can find the example usage for org.hibernate SQLQuery setInteger.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setInteger(int position, int val) 

Source Link

Document

Bind a positional int-valued parameter.

Usage

From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<PsOrder> findByCustomerId(final Integer id, final Short state) {
    log.debug("findByCustomerId: " + id);
    try {/*from   w  ww  . j av a  2 s.  c o m*/
        return getHibernateTemplate().executeFind(new HibernateCallback<List<PsOrder>>() {

            @Override
            public List<PsOrder> doInHibernate(Session arg0) throws HibernateException, SQLException {
                SQLQuery query = arg0
                        .createSQLQuery("select * from ps_order as P where P.id_customer = ? and P.status = ?");
                query.setInteger(0, id).setShort(1, state);
                query.addEntity(PsOrder.class);
                return query.list();

            }

        });
    } catch (RuntimeException re) {
        log.error("find by customerId failed", re);
        throw re;
    }
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<PsOrder> findByCustomerId(final Integer id) {
    log.debug("findByCustomerId: " + id);
    try {/*from w ww  . jav  a  2s.c o m*/
        return getHibernateTemplate().executeFind(new HibernateCallback<List<PsOrder>>() {

            @Override
            public List<PsOrder> doInHibernate(Session arg0) throws HibernateException, SQLException {
                SQLQuery query = arg0.createSQLQuery(
                        "select * from ps_order as P where P.id_customer = ? order by P.id desc");
                query.setInteger(0, id);
                query.addEntity(PsOrder.class);
                return query.list();

            }

        });
    } catch (RuntimeException re) {
        log.error("find by customerId failed", re);
        throw re;
    }
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<PsOrder> findByShopId(final Integer id, final Date from, final Date to) {
    log.debug("find by shop_id: " + id);
    try {//from w  ww .  j  ava2 s  .c o  m
        return getHibernateTemplate().executeFind(new HibernateCallback<List<PsOrder>>() {

            @Override
            public List<PsOrder> doInHibernate(Session arg0) throws HibernateException, SQLException {
                SQLQuery query = arg0.createSQLQuery(
                        "select * from ps_order as P where P.id_shop = ? and P.time_created > ? "
                                + " and P.time_created < ?");
                query.setInteger(0, id).setDate(1, from).setDate(2, to);
                query.addEntity(PsOrder.class);
                return query.list();

            }

        });
    } catch (RuntimeException re) {
        log.error("find by shop id failed", re);
        throw re;
    }
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<PsOrder> findByShopId(final Integer id) {
    log.debug("findByCustomerId: " + id);
    try {//from   ww  w.  j a v a 2  s.c  o  m
        return getHibernateTemplate().executeFind(new HibernateCallback<List<PsOrder>>() {
            @Override
            public List<PsOrder> doInHibernate(Session arg0) throws HibernateException, SQLException {
                SQLQuery query = arg0.createSQLQuery("select * from ps_order as P where P.id_shop = ?");
                query.setInteger(0, id);
                query.addEntity(PsOrder.class);
                return query.list();

            }

        });
    } catch (RuntimeException re) {
        log.error("find by shop id  failed", re);
        throw re;
    }
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<PsOrder> findByShopId(final Integer id, final Short state) {
    log.debug("findByCustomerId: " + id);
    try {/*from w w  w  .  j  a va 2s  .co m*/
        return getHibernateTemplate().executeFind(new HibernateCallback<List<PsOrder>>() {
            @Override
            public List<PsOrder> doInHibernate(Session arg0) throws HibernateException, SQLException {
                SQLQuery query = arg0
                        .createSQLQuery("select * from ps_order as P where P.id_shop = ? and P.status = ?");
                query.setInteger(0, id).setShort(1, state);
                query.addEntity(PsOrder.class);
                return query.list();

            }

        });
    } catch (RuntimeException re) {
        log.error("find by shop id  failed", re);
        throw re;
    }
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java

License:Open Source License

/**
         //from w ww.ja  va2 s  .com
select OD.* from ps_order as OD
 inner join ps_shop as SH on SH.id = OD.id_shop
where SH.id_seller = ?
        
         
 */

@Override
@SuppressWarnings("unchecked")
public List<PsOrder> findBySellerId(final Integer id) {
    return getHibernateTemplate().executeFind(new HibernateCallback<List<PsOrder>>() {

        @Override
        public List<PsOrder> doInHibernate(Session arg0) throws HibernateException, SQLException {

            SQLQuery query = arg0.createSQLQuery(" select OD.* from ps_order as OD "
                    + "         inner join ps_shop as SH on SH.id = OD.id_shop " + " where SH.id_seller = ?");
            query.addEntity(PsOrder.class);
            query.setInteger(0, id);
            return query.list();
        }
    });
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsRecipientDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  w  ww. j av a 2  s  .  c o m
public List<PsRecipient> findByCustomId(final Integer id) {
    return getHibernateTemplate().executeFind(new HibernateCallback<List<PsRecipient>>() {

        @Override
        public List<PsRecipient> doInHibernate(Session session) throws HibernateException, SQLException {
            SQLQuery q = session.createSQLQuery("select * from ps_recipient as RP where RP.id_customer = ?");
            q.setInteger(0, id);
            q.addEntity(PsRecipient.class);
            return q.list();
        }
    });
}

From source file:com.bitranger.parknshop.seller.dao.impl.PsShopDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//  ww w  .jav a2  s.  c o m
public List<PsShop> findBySellerId(final Integer id) {

    try {
        return getHibernateTemplate().executeFind(new HibernateCallback<List<PsShop>>() {
            @Override
            public List<PsShop> doInHibernate(Session session) throws HibernateException, SQLException {
                SQLQuery query = session.createSQLQuery("select * from ps_shop as P where P.id_seller = ?");

                query.setInteger(0, id);

                return query.addEntity(PsShop.class).list();
            }
        });
    } catch (RuntimeException re) {
        log.error("find by seller id failed", re);
        throw re;
    }
}

From source file:com.bitranger.parknshop.seller.dao.PsNoticeSellerDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//ww  w . ja va 2s .c o m
public List<PsNoticeSeller> getLatest(final int sellerID, final int n) {

    return getHibernateTemplate().executeFind(new HibernateCallback<List<PsNoticeSeller>>() {

        @Override
        public List<PsNoticeSeller> doInHibernate(Session arg0) throws HibernateException, SQLException {

            SQLQuery q = arg0.createSQLQuery(" select ps_notice_seller as NS "
                    + " where NS.is_valid = 1 and id_seller = ? " + " order by time_created desc limit ?");
            q.setInteger(0, sellerID);
            q.setInteger(1, n);
            q.addEntity(PsNoticeSeller.class);
            return q.list();
        }

    });
}

From source file:com.bookselling.dao.RatingDaoImpl.java

@Override
public double getAveragePoint(Serializable id) {
    SQLQuery query = getSession().createSQLQuery("  select avg(point) " + "  from rating "
            + "  where sellingPostId = :id " + "  group by sellingPostId  ");
    query.setInteger("id", (int) id);
    BigDecimal averagePoint = (BigDecimal) query.uniqueResult();
    return averagePoint != null ? averagePoint.doubleValue() : -1.0;
}