List of usage examples for org.hibernate SQLQuery addEntity
SQLQuery<T> addEntity(Class entityType);
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w .ja va2 s .c om public List<PsItem> findByCountPurchaseInTag(final Integer psTagId, final FetchOption op) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery( "select P.* from ps_item as P where P.id in (select R.id_item from r_tag_item as R where R.id_tag = ? ) " + "order by count_purchase " + (op.sortOption == SortOption.ASCENDING ? "asc" : "desc ") + "limit ?, ?"); query.setInteger(0, psTagId).setInteger(1, op.offset).setInteger(2, op.limit); return query.addEntity(PsItem.class).list(); } }); } catch (RuntimeException re) { log.error("find by findByCountPurchaseInTag failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from ww w.j av a 2 s .c o m public List<PsItem> findByCountFavouriteInTag(final Integer psTagId, final FetchOption op) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery( "select P.* from ps_item as P where P.id in (select R.id_item from r_tag_item as R where R.id_tag = ? ) " + "order by count_favourite " + (op.sortOption == SortOption.ASCENDING ? "asc" : "desc ") + "limit ?, ?"); query.setInteger(0, psTagId).setInteger(1, op.offset).setInteger(2, op.limit); return query.addEntity(PsItem.class).list(); } }); } catch (RuntimeException re) { log.error("find by findByCountFavouriteInTag failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w.ja v a 2 s . co m public List<PsItem> findByVoteInTag(final Integer psTagId, final FetchOption op) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery( "select P.* from ps_item as P where P.id in (select R.id_item from r_tag_item as R where R.id_tag = ? ) " + "order by vote " + (op.sortOption == SortOption.ASCENDING ? "asc" : "desc ") + "limit ?, ?"); query.setInteger(0, psTagId).setInteger(1, op.offset).setInteger(2, op.limit); return query.addEntity(PsItem.class).list(); } }); } catch (RuntimeException re) { log.error("find by findByVoteInTag failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* ww w.j av a 2 s . com*/ public List<PsItem> findByOrderId(final Integer id) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery( "select P.* from ps_item as P where P.id in (select R.id_item from r_order_item as R where R.id_order = ? ) "); query.setInteger(0, id); query.addEntity(PsItem.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by findByOrderId failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w. j a v a 2 s.co m public List<PsItem> findBySeller(final Integer sellerId, final FetchOption fetchOption) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery( "select P.* from ps_item as P where P.id_shop in (select S.id from ps_shop as S where S.id_seller = ? ) "); query.setInteger(0, sellerId); query.addEntity(PsItem.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by findBySeller failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w . ja v a 2 s. co m public List<PsItem> findByShop(final Integer shopId, final FetchOption fetchOption) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery("select * from ps_item as P where P.id_shop = ? " + "order by name " + (fetchOption.sortOption == SortOption.ASCENDING ? "asc" : "desc ") + "limit ?, ?"); query.setInteger(0, shopId).setInteger(1, fetchOption.offset).setInteger(2, fetchOption.limit); query.addEntity(PsItem.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by findByShop failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from www .j a v a 2s . c o m public List<PsItem> findByCountPurchase(final FetchOption op) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery("select * from ps_item " + "order by count_purchase " + (op.sortOption == SortOption.ASCENDING ? "asc" : "desc ") + "limit ?, ?"); query.setInteger(0, op.offset).setInteger(1, op.limit); query.addEntity(PsItem.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by findByCountPurchase failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from www . j a v a2 s. co m*/ public List<PsItem> findByCountFavourite(final FetchOption op) { try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItem>>() { @Override public List<PsItem> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery(" select * from ps_item " + " order by count_favourite " + (op.sortOption == SortOption.ASCENDING ? " asc " : " desc ") + " limit ?, ?"); query.setInteger(0, op.offset).setInteger(1, op.limit); query.addEntity(PsItem.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by findByCountFavourite failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsItemInfoDAO.java
License:Open Source License
@Override @SuppressWarnings({ "unchecked" }) public List<PsItemInfo> findByItemId(final java.lang.Integer id) { try {/* w w w . jav a2 s .c o m*/ return getHibernateTemplate().executeFind(new HibernateCallback<List<PsItemInfo>>() { @Override public List<PsItemInfo> doInHibernate(Session session) throws HibernateException, SQLException { SQLQuery query = session.createSQLQuery("select * from ps_item_info where id_item = ? "); query.setInteger(0, id); query.addEntity(PsItemInfo.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by findByItemId failed", re); throw re; } }
From source file:com.bitranger.parknshop.common.dao.impl.PsRecipientDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w. jav a2s. c o m public List<PsRecipient> findByCustomId(final Integer id) { log.debug("findByCustomerId: " + id); try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsRecipient>>() { @Override public List<PsRecipient> doInHibernate(Session arg0) throws HibernateException, SQLException { SQLQuery query = arg0.createSQLQuery("select * from ps_recipient as P where P.id_customer = ?"); query.setInteger(0, id); query.addEntity(PsRecipient.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find by customerId failed", re); throw re; } }