List of usage examples for org.hibernate SQLQuery addEntity
SQLQuery<T> addEntity(Class entityType);
From source file:com.bitranger.parknshop.seller.dao.impl.PsOrderDAO.java
License:Open Source License
/** /*from w w w . ja v a 2 s . c om*/ 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 w w . j ava2 s . co 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.PsSellerDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w. j a v a 2 s .c o m public List<PsSeller> findAll(final FetchOption fetchOption) { log.debug("find all PsSeller"); try { return getHibernateTemplate().executeFind(new HibernateCallback<List<PsSeller>>() { @Override public List<PsSeller> doInHibernate(Session arg0) throws HibernateException, SQLException { SQLQuery query = arg0.createSQLQuery("select * from ps_seller as P order by P.id " + (fetchOption.sortOption == SortOption.ASCENDING ? "asc" : "desc")); query.addEntity(PsSeller.class); return query.list(); } }); } catch (RuntimeException re) { log.error("find all PsSeller failed", re); throw re; } }
From source file:com.bitranger.parknshop.seller.dao.impl.PsShopDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from ww w.j ava 2s . co 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.impl.PsShopDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// w w w. ja v a2s .c om public List<PsShop> findAllSortByVote(final FetchOption op) { 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 order by vote " + (op.sortOption == SortOption.ASCENDING ? "asc" : "desc")); return query.addEntity(PsShop.class).list(); } }); } catch (RuntimeException re) { log.error("find all seller failed", re); throw re; } }
From source file:com.bitranger.parknshop.seller.dao.impl.PsShopDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w ww. j a v a2 s. c o m*/ public List<PsShop> findAllSortByName(final FetchOption op) { 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 order by name " + (op.sortOption == SortOption.ASCENDING ? "asc" : "desc")); return query.addEntity(PsShop.class).list(); } }); } catch (RuntimeException re) { log.error("find all seller failed", re); throw re; } }
From source file:com.bitranger.parknshop.seller.dao.PsNoticeSellerDAO.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w ww.j a va 2 s .co 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.br.uepb.dao.MedicaoBalancaDAO.java
License:Open Source License
/** * Metodo para listar a ultima medio do paciente cadastrada * @param idPaciente int// w w w .j a va 2s . c om * @return MedicaoBalancaDomain */ public MedicaoBalancaDomain obtemUltimaMedicao(int idPaciente) { String comando = "select mb.* from medicao_balanca mb " + "where mb.paciente_id = :idPaciente " + "order by data_hora desc " + "limit 1"; SQLQuery query = SessaoAtual().createSQLQuery(comando); query.setParameter("idPaciente", idPaciente); query.addEntity(MedicaoBalancaDomain.class); MedicaoBalancaDomain medicao = (MedicaoBalancaDomain) query.uniqueResult(); return medicao; }
From source file:com.br.uepb.dao.MedicaoOximetroDAO.java
License:Open Source License
/** * Mtodo para obter a ultima medio cadastrada de acordo com o id do paciente * @param idPaciente Id do paciente//from w ww . j av a 2 s. c o m * @return MedicaoOximetroDomain */ public MedicaoOximetroDomain obtemUltimaMedicao(int idPaciente) { String comando = "select mo.* from Medicao_oximetro mo " + "where mo.paciente_id = :idPaciente " + "order by data_hora desc " + "limit 1"; SQLQuery query = SessaoAtual().createSQLQuery(comando); query.setParameter("idPaciente", idPaciente); query.addEntity(MedicaoOximetroDomain.class); MedicaoOximetroDomain medicao = (MedicaoOximetroDomain) query.uniqueResult(); return medicao; }
From source file:com.br.uepb.dao.MedicaoPressaoDAO.java
License:Open Source License
/** * Mtodo para obter a ultima medio cadastrada * @param idPaciente Id do paciente//from www. ja v a2 s .c o m * @return MedicaoPressaoDomain */ public MedicaoPressaoDomain obtemUltimaMedicao(int idPaciente) { String comando = "select mp.* from medicao_pressao mp " + "where mp.paciente_id = :idPaciente " + "order by data_hora desc " + "limit 1"; SQLQuery query = SessaoAtual().createSQLQuery(comando); query.setParameter("idPaciente", idPaciente); query.addEntity(MedicaoPressaoDomain.class); MedicaoPressaoDomain medicao = (MedicaoPressaoDomain) query.uniqueResult(); return medicao; }