List of usage examples for org.hibernate Query setBigDecimal
@Deprecated @SuppressWarnings("unchecked") default Query<R> setBigDecimal(String name, BigDecimal val)
From source file:com.netsteadfast.greenstep.base.dao.BaseDAO.java
License:Apache License
/** * for public QueryResult getList... doInHibernate * @param query JPA-Style : from TB_ACCOUNT where account = ?0 * @param position JPA-Style : "0", "1" ..... * @param params/*w w w.ja v a 2 s . c om*/ */ @SuppressWarnings("rawtypes") private void setQueryParams(Query query, String position, Object params) { if (params instanceof java.lang.String) { query.setString(position, (java.lang.String) params); return; } if (params instanceof java.lang.Character) { query.setCharacter(position, (java.lang.Character) params); return; } if (params instanceof java.lang.Double) { query.setDouble(position, (java.lang.Double) params); return; } if (params instanceof java.lang.Byte) { query.setByte(position, (java.lang.Byte) params); return; } if (params instanceof java.lang.Integer) { query.setInteger(position, (java.lang.Integer) params); return; } if (params instanceof java.lang.Long) { query.setLong(position, (java.lang.Long) params); return; } if (params instanceof java.lang.Boolean) { query.setBoolean(position, (java.lang.Boolean) params); return; } if (params instanceof java.math.BigDecimal) { query.setBigDecimal(position, (java.math.BigDecimal) params); return; } if (params instanceof java.util.Date) { query.setDate(position, (java.util.Date) params); return; } if (params instanceof java.util.List) { List listParams = (List) params; this.setQueryParamsOfList(query, position, listParams); return; } }
From source file:com.qcadoo.model.internal.search.SearchQueryImpl.java
License:Open Source License
@Override public void addParameters(final Query query) { for (Map.Entry<String, String> parameter : strings.entrySet()) { query.setString(parameter.getKey(), parameter.getValue()); }/*from www . j a va 2s . com*/ for (Map.Entry<String, Boolean> parameter : booleans.entrySet()) { query.setBoolean(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Byte> parameter : bytes.entrySet()) { query.setByte(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Short> parameter : shorts.entrySet()) { query.setShort(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Integer> parameter : integers.entrySet()) { query.setInteger(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Long> parameter : longs.entrySet()) { query.setLong(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Float> parameter : floats.entrySet()) { query.setFloat(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Double> parameter : doubles.entrySet()) { query.setDouble(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, BigDecimal> parameter : bigDecimals.entrySet()) { query.setBigDecimal(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Date> parameter : dates.entrySet()) { query.setDate(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Date> parameter : times.entrySet()) { query.setTime(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Date> parameter : timestamps.entrySet()) { query.setTimestamp(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Object> parameter : parameters.entrySet()) { query.setParameter(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Collection<? extends Object>> parametersList : parameterLists.entrySet()) { query.setParameterList(parametersList.getKey(), parametersList.getValue()); } for (Map.Entry<String, Object> parameter : entities.entrySet()) { query.setEntity(parameter.getKey(), parameter.getValue()); } }
From source file:com.spring.model.ExpedienteModel.java
public void deleteExpedienteById(BigDecimal codExpediente) { Query query = getSession().createSQLQuery("delete from expediente where cod_expediente = :cod_expediente"); query.setBigDecimal("cod_expediente", codExpediente); query.executeUpdate();/*from www.j a va2 s. c o m*/ }
From source file:com.spring.model.PersonaModel.java
public void deletePersonaById(BigDecimal codPersona) { Query query = getSession().createSQLQuery("delete from persona where cod_persona = :cod_persona"); query.setBigDecimal("cod_persona", codPersona); query.executeUpdate();//www. j a va 2 s .co m }
From source file:com.spring.model.SesionModel.java
public void deleteExpedienteById(BigDecimal codSesion) { Query query = getSession().createSQLQuery("delete from sesion where cod_sesion = :cod_sesion"); query.setBigDecimal("cod_sesion", codSesion); query.executeUpdate();/*from ww w.j a va 2s. c om*/ }
From source file:com.spring.model.SesionModel.java
@SuppressWarnings("unchecked") public String findAllSesionesById(BigDecimal cod_tratamiento) { String q = "select * from sesion where id_tratamiento = :cod_tratamiento"; Query query = getSession().createSQLQuery(q); query.setBigDecimal("cod_tratamiento", cod_tratamiento); List<Object> results = query.list(); String sesiones = new Gson().toJson(results); return sesiones; }
From source file:com.spring.model.TratamientoModel.java
public void deleteExpedienteById(BigDecimal codTratamiento) { Query query = getSession() .createSQLQuery("delete from tratamiento where cod_tratamiento = :cod_tratamiento"); query.setBigDecimal("cod_tratamiento", codTratamiento); query.executeUpdate();/* ww w . j a v a 2 s . c o m*/ }
From source file:com.spring.model.UsuarioModel.java
public void deleteUsuarioById(BigDecimal codUsuario) { Query query = getSession().createSQLQuery("delete from usuario where cod_usuario = :cod_usuario"); query.setBigDecimal("cod_usuario", codUsuario); query.executeUpdate();//from w ww . jav a 2s . co m }
From source file:com.spring.model.UsuarioModel.java
public String getClinica(BigDecimal codU) { String q = "select nombre from usuario natural join empleado natural join clinica where cod_usuario = :cod"; Query query = getSession().createSQLQuery(q); query.setBigDecimal("cod", codU); String result = (String) query.uniqueResult(); return result; }
From source file:com.ues.too115.sistemabibliotecariomaven.service.MunicipioService.java
public List<Municipio> getByDepartamento(int id) { List<Municipio> municipios = new ArrayList<Municipio>(); Session session = NewHibernateUtil.getSessionFactory().openSession(); try {/*from w w w. jav a 2 s . c o m*/ Transaction transaction = session.beginTransaction(); String hql = "from Municipio where iddepartamento = :iddepartamento"; Query query = session.createQuery(hql); query.setBigDecimal("iddepartamento", BigDecimal.valueOf(id)); municipios = query.list(); transaction.commit(); } catch (HibernateException e) { session.getTransaction().rollback(); e.printStackTrace(); } return municipios; }