List of usage examples for org.hibernate Query setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(String name, String val)
From source file:com.google.code.mymon3y.persistencia.dao.hibernate.TransacaoDAOHibernate.java
License:Open Source License
/** * @see com.google.code.mymon3y.persistencia.dao.TransacaoDAO#getNumeroDeTransacoes(java.lang.String) *///from w w w .j ava2 s . com public Long getNumeroDeTransacoes(final String login) throws PersistenciaMyMon3yException { Long result = null; result = (Long) executarOperacao(new Comando() { public Object executar() { Query q = getSession().getNamedQuery("transacao.loginDoUsuario"); q.setString("loginDoUsuario", login); return q.uniqueResult(); } }); return result; }
From source file:com.google.code.mymon3y.persistencia.dao.hibernate.TransacaoDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") /* (non-Javadoc)/*from ww w .java 2 s. c om*/ * @see com.google.code.mymon3y.persistencia.dao.TransacaoDAO#getTransacoes(java.lang.String) */ @Override public List<Transacao> getTransacoes(final String login) throws PersistenciaMyMon3yException { List<Transacao> result = null; result = (List<Transacao>) executarOperacao(new Comando() { public Object executar() { Query q = getSession().getNamedQuery("transacao.todasTransacoesLoginDoUsuario"); q.setString("loginDoUsuario", login); return q.list(); } }); return result; }
From source file:com.google.code.mymon3y.persistencia.dao.hibernate.TransacaoDAOHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") /* (non-Javadoc)//from w w w .jav a 2 s.c o m * @see com.google.code.mymon3y.persistencia.dao.TransacaoDAO#getTransacoes(java.lang.String, java.lang.Long) */ @Override public List<Transacao> getTransacoes(final String login, final Long idCategoria) throws PersistenciaMyMon3yException { List<Transacao> result = null; result = (List<Transacao>) executarOperacao(new Comando() { public Object executar() { Query q = getSession().getNamedQuery("transacao.todasTransacoesLoginDoUsuarioIdCategoria"); q.setString("loginDoUsuario", login); q.setLong("idCategoria", idCategoria); return q.list(); } }); return result; }
From source file:com.google.code.mymon3y.persistencia.dao.hibernate.UsuarioDAOHibernate.java
License:Open Source License
/** * @see com.google.code.mymon3y.persistencia.dao.UsuarioDAO#findByLogin(java.lang.String) *///from w w w . j av a2 s . c om public Usuario findByLogin(final String login) throws PersistenciaMyMon3yException { Usuario result = null; result = (Usuario) executarOperacao(new Comando() { public Object executar() { Query q = getSession().getNamedQuery("usuario.login"); q.setString("login", login); return q.list().size() > 0 ? q.list().get(0) : null; } }); fazerAntesDoLoadSessaoFechada(result); return result; }
From source file:com.googlecode.sarasvati.hib.HibGraphRepository.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from www . j a va 2 s .c om public List<HibGraph> getGraphs(final String name) { Query query = session.createQuery("from HibGraph where name = :name "); query.setString("name", name); return query.list(); }
From source file:com.hasz.dao.ClienteDAO.java
public static ClienteFisico buscarClienteFisicoByLoginSenha(String login, String senha) { Session sessao = HibernateUtil.getSession(); ClienteFisico retorno = null;//w w w .jav a 2 s . co m try { Query select = sessao.createQuery("from ClienteFisico where cpf = :login and senha = :senha"); select.setString("login", login); select.setString("senha", senha); List<ClienteFisico> c = select.list(); if (c.size() == 1) retorno = c.get(0); } catch (Exception e) { e.printStackTrace(); } finally { sessao.close(); return retorno; } }
From source file:com.hihsoft.baseclass.service.impl.BaseServiceImpl.java
License:Apache License
/** * ???/*from w ww. ja v a 2s . co m*/ * * @param user * @return * @author Xiaojf * @since 2011-6-13 */ public String getMenus(final TaclUserinfo user, final String flatid) { if (StringHelpers.isNull(flatid)) return "[]"; return baseDAO.doInHibernate(new HibernateCallback<String>() { @SuppressWarnings("unchecked") public String doInHibernate(Session session) throws HibernateException, SQLException { TsysFlat flat = (TsysFlat) session.get(TsysFlat.class, flatid); Set<TsysModuleinfo> set = flat.getTsysModuleinfos(); // Query query = session // .createSQLQuery("select distinct moduleid from (select // moduleid from t_acl_roleprivilege where roleid in (select // roleid from t_acl_roleuser where userid=?) union all select // moduleid from t_acl_userprivilege where userid=?)"); Query query = session.createSQLQuery( "SELECT MODULEID FROM T_SYS_MODULEINFO WHERE MODULEID IN(SELECT DISTINCT T.MODULEID FROM (SELECT R.MODULEID FROM T_ACL_ROLEPRIVILEGE R WHERE R.ROLEID IN (SELECT US.ROLEID FROM T_ACL_ROLEUSER US WHERE US.USERID=?) UNION ALL SELECT AC.MODULEID FROM T_ACL_USERPRIVILEGE AC WHERE AC.USERID=?) T) ORDER BY SORTNUM"); query.setString(0, user.getUserid()); query.setString(1, user.getUserid()); List<String> assinged = query.list(); List<Map<String, Object>> menus = new ArrayList<Map<String, Object>>(); for (TsysModuleinfo info : set) { if (!StringUtils.isNullOrEmpty(info.getParentmoduleid())) continue; if (!assinged.contains(info.getModuleid())) { continue; } Map<String, Object> menu = new LinkedHashMap<String, Object>(); eachMenu(info, menu, assinged); if (!menu.isEmpty()) menus.add(menu); } return JsonUtil.toString(menus); } }); }
From source file:com.hihsoft.sso.business.service.impl.TaclRoleServiceImpl.java
License:Apache License
/** * ?TaclRole?// w w w . j a v a 2 s .c o m * * @param id * @throws DataAccessException */ public TaclRole getTaclRoleById(final String id) throws ServiceException { return baseDAO.doInHibernate(new HibernateCallback<TaclRole>() { @Override public TaclRole doInHibernate(Session session) throws HibernateException, SQLException { TaclRole taclRole = null; Query query = session.createQuery(TACLROLEById_HQL); query.setString(0, id); List<?> list = query.list(); if (!list.isEmpty() && list.size() > 0) { taclRole = (TaclRole) list.get(0); Hibernate.initialize(taclRole.getTaclRoleusers()); } return taclRole; } }); }
From source file:com.hihsoft.sso.business.service.impl.TaclRoleServiceImpl.java
License:Apache License
public List<TaclRoleuser> getTaclRoleUserByRoleId(final String id) throws ServiceException { return baseDAO.doInHibernate(new HibernateCallback<List<TaclRoleuser>>() { @Override//from ww w. j a v a2s .c om public List<TaclRoleuser> doInHibernate(Session session) throws HibernateException, SQLException { TaclRole taclRole = null; Query query = session.createQuery(TACLROLEById_HQL); query.setString(0, id); List<?> list = query.list(); if (!list.isEmpty() && list.size() > 0) { taclRole = (TaclRole) list.get(0); Hibernate.initialize(taclRole.getTaclRoleusers()); return new ArrayList<TaclRoleuser>(taclRole.getTaclRoleusers()); } return new ArrayList<TaclRoleuser>(); } }); }