List of usage examples for org.hibernate Query setResultTransformer
@Deprecated Query<R> setResultTransformer(ResultTransformer transformer);
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<String> datosLicitacion(String numeroLicitacion) throws DAOException {//Querys con nombre y variables de las clases! try {//w ww. j a va 2s . c o m System.out.println("&&- REALIZA QUERY [DATOS-PARTICIPANTE] -&&"); Query queryObject = sessionFactory.getCurrentSession() .createQuery("SELECT o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS fechaJunta,o.fechaApertura AS fechaApertura,o.fechaVisita AS fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS estado,o.capital AS capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS dependencia," + "o.descripcion AS descripcion,o.notas AS notas,o.numeroOportunidad AS numeroOportunidad,om.volumen AS volumen,om.clave AS clave,om.notas AS notasp, c.cliente AS cliente " + "FROM Oportunidad o,OportunidadMaterial om,Producto p,OportunidadParticipante op,Cliente c " + "WHERE o.id=om.oportunidad and p.clave=om.clave and o.id=op.oportunidad and c.idCliente=op.cliente " + "and o.numeroLicitacion= :numeroLicitacion".toString()) .setParameter("numeroLicitacion", numeroLicitacion); System.out.println("&&- QUERY GENERADO [DATOS-PARTICIPANTE] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans.Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("Producto", Producto.class); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadMaterial", OportunidadMaterial.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [DATOS-PARTICIPANTE] -&&"); return queryObject.list(); //return (ArrayList<String>) queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception Null-%-% : " + n); throw n; } catch (HibernateException h) { System.out.println("%-%-Exception HIBERNATE-%-% : " + h); throw new RuntimeException(h); } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<String> datosLicitacionb(String numeroLicitacion) throws DAOException {//Querys con nombre y variables de las clases! try {/* ww w . j av a 2 s. c o m*/ System.out.println("&&- REALIZA QUERY [DATOS-PARTICIPANTE] -&&"); Query queryObject = sessionFactory.getCurrentSession() .createQuery("SELECT o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS fechaJunta,o.fechaApertura AS fechaApertura,o.fechaVisita AS fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS estado,o.capital AS capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS dependencia," + "o.descripcion AS descripcion,o.notas AS notas,o.numeroOportunidad AS numeroOportunidad,om.volumen AS volumen,om.clave AS clave,om.notas AS notasp, c.cliente AS cliente " + "FROM Oportunidad o,OportunidadMaterial om,ProductoBajio pb,OportunidadParticipante op,Cliente c " + "WHERE o.id=om.oportunidad and pb.clave=om.clave and o.id=op.oportunidad and c.idCliente=op.cliente " + "and o.numeroLicitacion= :numeroLicitacion".toString()) .setParameter("numeroLicitacion", numeroLicitacion); System.out.println("&&- QUERY GENERADO [DATOS-PARTICIPANTE] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans.Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("ProductoBajio", ProductoBajio.class); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadMaterial", OportunidadMaterial.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [DATOS-PARTICIPANTE] -&&"); return queryObject.list(); //return (ArrayList<String>) queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception Null-%-% : " + n); throw n; } catch (HibernateException h) { System.out.println("%-%-Exception HIBERNATE-%-% : " + h); throw new RuntimeException(h); } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<String> datosLicitacions(String numeroLicitacion) throws DAOException {//Querys con nombre y variables de las clases! try {//from w w w .j a v a 2 s .c om System.out.println("&&- REALIZA QUERY [DATOS-PARTICIPANTE] -&&"); Query queryObject = sessionFactory.getCurrentSession() .createQuery("SELECT o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS fechaJunta,o.fechaApertura AS fechaApertura,o.fechaVisita AS fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS estado,o.capital AS capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS dependencia," + "o.descripcion AS descripcion,o.notas AS notas,o.numeroOportunidad AS numeroOportunidad,om.volumen AS volumen,om.clave AS clave,om.notas AS notasp, c.cliente AS cliente " + "FROM Oportunidad o,OportunidadMaterial om,ProductoSureste ps,OportunidadParticipante op,Cliente c " + "WHERE o.id=om.oportunidad and ps.clave=om.clave and o.id=op.oportunidad and c.idCliente=op.cliente " + "and o.numeroLicitacion= :numeroLicitacion".toString()) .setParameter("numeroLicitacion", numeroLicitacion); System.out.println("&&- QUERY GENERADO [DATOS-PARTICIPANTE] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans.Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("ProductoSureste", ProductoSureste.class); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadMaterial", OportunidadMaterial.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [DATOS-PARTICIPANTE] -&&"); return queryObject.list(); //return (ArrayList<String>) queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception Null-%-% : " + n); throw n; } catch (HibernateException h) { System.out.println("%-%-Exception HIBERNATE-%-% : " + h); throw new RuntimeException(h); } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<String> buscaOportunidadxId(int id) throws DAOException { // List list = getHibernateTemplate().find("from Oportunidad WHERE id=?", id); // return (Oportunidad) list.get(0); try {/*from w w w .j a v a2s. c om*/ System.out.println("&&- REALIZA QUERY [DATOS-COTIZACION] -&&"); /* * Query queryObject = * sessionFactory.getCurrentSession().createQuery("SELECT o.id AS * id,o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS * fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS * fechaJunta, o.status AS status,o.cotizado AS * cotizado,o.fechaApertura AS fechaApertura,o.fechaVisita AS * fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS * estado,o.municipio AS municipio,o.capital AS * capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS * dependencia," + "o.descripcion AS descripcion,o.notas AS * notas,o.numeroOportunidad AS numeroOportunidad,om.montoTotal AS * montoTotal,om.clave AS clave, c.cliente AS cliente," + * "om.volumen AS volumen, om.notas AS notasp,o.empleado AS * empleado,o.ejecutivo AS ejecutivo, o.ultimaModificacion AS * ultimaModificacion,p.costo AS costo," + "o.planta AS planta " + * "FROM Oportunidad o LEFT JOIN OportunidadMaterial om ON * o.id=om.oportunidad " + "FULL OUTER JOIN Producto p ON * p.clave=om.clave, " + "Cliente c,OportunidadParticipante op " + * "WHERE "//p.clave=om.clave OR pb.clave=om.clave OR * ps.clave=om.clave + "om.oportunidad IS NULL AND * op.cliente=c.idCliente AND op.oportunidad=o.id " + "AND o.id= :id * ".toString()).setParameter("id", id); */ Query queryObject = sessionFactory.getCurrentSession().createQuery( "SELECT o.id AS id,o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS fechaJunta, o.status AS status,o.cotizado AS cotizado,o.fechaApertura AS fechaApertura,o.fechaVisita AS fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS estado,o.municipio AS municipio,o.capital AS capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS dependencia," + "o.descripcion AS descripcion,o.notas AS notas,o.numeroOportunidad AS numeroOportunidad,om.montoTotal AS montoTotal,om.clave AS clave, c.cliente AS cliente," + "om.pproductoOptimo AS precioOptimo,om.ubOptimo AS ubOptimo,om.precioProducto AS precioMinimo,om.ub AS ubMinimo,om.precioFlete AS precioFlete," + "om.pfinalOptimo AS precioFinalOptimo,om.acotizar AS acotizar,om.id AS idOM," + "om.volumen AS volumen, om.notas AS notasp,o.empleado AS empleado,o.ejecutivo AS ejecutivo, o.ultimaModificacion AS ultimaModificacion,p.costo AS costo," + "o.planta AS planta,o.nivel AS nivel,o.clasifi AS clasifi,o.fleteTrailer AS fleteTrailer, o.fleteTorton AS fleteTorton,o.montoOportunidad AS montoOportunidad," + "o.contadorOportunidad AS contadorOportunidad,c.idCliente AS idCliente " + "FROM Oportunidad o,OportunidadMaterial om,Producto p," + "Cliente c,OportunidadParticipante op " + "WHERE "//p.clave=om.clave OR pb.clave=om.clave OR ps.clave=om.clave + "o.id=om.oportunidad AND p.clave=om.clave AND op.cliente=c.idCliente AND op.oportunidad=o.id " + "AND o.id= :id group by om.clave".toString()) .setParameter("id", id); System.out.println("&&- QUERY GENERADO [DATOS-COTIZACION] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans(DTO).Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadMaterial", OportunidadMaterial.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); miMap.put("Producto", Producto.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [DATOS-COTIZACION] -&&"); // queryObject.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return queryObject.list(); //return (ArrayList<String>) queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception NULL-%-% : " + n); throw n; } catch (HibernateException h) { System.out.println("%-%-Exception HIBERNATE-%-% : " + h); throw new RuntimeException(h); } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<String> buscaOportunidadBxId(int id) throws DAOException { // List list = getHibernateTemplate().find("from Oportunidad WHERE id=?", id); // return (Oportunidad) list.get(0); try {/*from w w w .ja va 2s . c om*/ System.out.println("&&- REALIZA QUERY [DATOS-COTIZACION] -&&"); Query queryObject = sessionFactory.getCurrentSession().createQuery( "SELECT o.id AS id,o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS fechaJunta, o.status AS status,o.cotizado AS cotizado,o.fechaApertura AS fechaApertura,o.fechaVisita AS fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS estado,o.municipio AS municipio,o.capital AS capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS dependencia," + "o.descripcion AS descripcion,o.notas AS notas,o.numeroOportunidad AS numeroOportunidad,om.montoTotal AS montoTotal,om.clave AS clave, c.cliente AS cliente," + "om.pproductoOptimo AS precioOptimo,om.ubOptimo AS ubOptimo,om.precioProducto AS precioMinimo,om.ub AS ubMinimo,om.precioFlete AS precioFlete," + "om.pfinalOptimo AS precioFinalOptimo,om.acotizar AS acotizar,om.id AS idOM," + "om.volumen AS volumen, om.notas AS notasp,o.empleado AS empleado,o.ejecutivo AS ejecutivo, o.ultimaModificacion AS ultimaModificacion,pb.costo AS costo, " + "o.planta AS planta,o.nivel AS nivel,o.clasifi AS clasifi,o.fleteTrailer AS fleteTrailer, o.fleteTorton AS fleteTorton,o.montoOportunidad AS montoOportunidad," + "o.contadorOportunidad AS contadorOportunidad,c.idCliente AS idCliente " + "FROM Oportunidad o,OportunidadMaterial om,ProductoBajio pb," + "Cliente c,OportunidadParticipante op " + "WHERE "//p.clave=om.clave OR pb.clave=om.clave OR ps.clave=om.clave + "o.id=om.oportunidad AND pb.clave=om.clave AND op.cliente=c.idCliente AND op.oportunidad=o.id " + "AND o.id= :id".toString()) .setParameter("id", id); System.out.println("&&- QUERY GENERADO [DATOS-COTIZACION] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans(DTO).Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadMaterial", OportunidadMaterial.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); miMap.put("ProductoBajio", ProductoBajio.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [DATOS-COTIZACION] -&&"); return queryObject.list(); //return (ArrayList<String>) queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception NULL-%-% : " + n); throw n; } catch (HibernateException h) { System.out.println("%-%-Exception HIBERNATE-%-% : " + h); throw new RuntimeException(h); } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<String> buscaOportunidadSxId(int id) throws DAOException { // List list = getHibernateTemplate().find("from Oportunidad WHERE id=?", id); // return (Oportunidad) list.get(0); try {/* www . j a va2 s . co m*/ System.out.println("&&- REALIZA QUERY [DATOS-COTIZACION] -&&"); Query queryObject = sessionFactory.getCurrentSession().createQuery( "SELECT o.id AS id,o.numeroLicitacion AS numeroLicitacion, o.fechaRegistro AS fechaRegistro," + "o.fechaBases AS fechaBases,o.fechaJunta AS fechaJunta, o.status AS status,o.cotizado AS cotizado,o.fechaApertura AS fechaApertura,o.fechaVisita AS fechaVisita," + "o.fechaFallo AS fechaFallo,o.estado AS estado,o.municipio AS municipio,o.capital AS capital,o.ubicacionObra AS ubicacionObra,o.dependencia AS dependencia," + "o.descripcion AS descripcion,o.notas AS notas,o.numeroOportunidad AS numeroOportunidad,om.montoTotal AS montoTotal,om.clave AS clave, c.cliente AS cliente," + "om.pproductoOptimo AS precioOptimo,om.ubOptimo AS ubOptimo,om.precioProducto AS precioMinimo,om.ub AS ubMinimo,om.precioFlete AS precioFlete," + "om.pfinalOptimo AS precioFinalOptimo,om.acotizar AS acotizar,om.id AS idOM," + "om.volumen AS volumen, om.notas AS notasp,o.empleado AS empleado,o.ejecutivo AS ejecutivo, o.ultimaModificacion AS ultimaModificacion,ps.costo AS costo, " + "o.planta AS planta,o.nivel AS nivel,o.clasifi AS clasifi,o.fleteTrailer AS fleteTrailer, o.fleteTorton AS fleteTorton,o.montoOportunidad AS montoOportunidad," + "o.contadorOportunidad AS contadorOportunidad,c.idCliente AS idCliente " + "FROM Oportunidad o,OportunidadMaterial om,ProductoSureste ps," + "Cliente c,OportunidadParticipante op " + "WHERE "//p.clave=om.clave OR pb.clave=om.clave OR ps.clave=om.clave + "o.id=om.oportunidad AND ps.clave=om.clave AND op.cliente=c.idCliente AND op.oportunidad=o.id " + "AND o.id= :id".toString()) .setParameter("id", id); System.out.println("&&- QUERY GENERADO [DATOS-COTIZACION] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans(DTO).Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadMaterial", OportunidadMaterial.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); miMap.put("ProductoSureste", ProductoSureste.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [DATOS-COTIZACION] -&&"); return queryObject.list(); //return (ArrayList<String>) queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception NULL-%-% : " + n); throw n; } catch (HibernateException h) { System.out.println("%-%-Exception HIBERNATE-%-% : " + h); throw new RuntimeException(h); } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<OportunidadParticipante> participantexIdOportunidad(int idOp) throws DAOException { try {/*from www .j a v a 2s. com*/ System.out.println("&&- REALIZA QUERY [PARTICIPANTE X ID OPORTUNIDAD] -&&"); Query queryObject = sessionFactory.getCurrentSession() .createQuery("SELECT op.id AS id,c.idCliente AS idCliente,c.cliente AS cliente " + "FROM Oportunidad o, Cliente c, OportunidadParticipante op " + "WHERE c.idCliente=op.cliente AND o.id=op.oportunidad and o.id=:idOportunidad" .toString()) .setParameter("idOportunidad", idOp); System.out.println("&&- QUERY GENERADO [PARTICIPANTE X ID OPORTUNIDAD] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans.Se adiere toString() al query */ Map<String, Object> miMap = new HashMap<String, Object>(); miMap.put("Cliente", Cliente.class); miMap.put("Oportunidad", Oportunidad.class); miMap.put("OportunidadParticipante", OportunidadParticipante.class); queryObject.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); System.out.println("&&- ENVIA LISTA [PARTICIPANTE X ID OPORTUNIDAD] FULL -&&"); return queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception Null-%-% : " + n); throw n; } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:mx.com.tubocreto.dao.Impl.OportunidadDaoImpl.java
@Override public List<Oportunidad> ubicacionObraOportunidad() throws DAOException {//Querys con nombre y variables de las clases! try {/*from w w w . j a v a 2 s. c o m*/ System.out.println("&&- REALIZA QUERY [OBRA DE OPORTUNIDAD] -&&"); Query queryObject = sessionFactory.getCurrentSession() .createQuery("SELECT o.ubicacionObra AS ubicacionObra, o.numeroLicitacion AS numeroLicitacion " + "FROM Oportunidad o".toString()); System.out.println("&&- QUERY GENERADO [OBRA DE OPORTUNIDAD] -&&"); /* * Convierte resultado de Query en cadena JSON, a partir del * toString() de los beans.Se adiere toString() al query */ queryObject.setResultTransformer(Transformers.aliasToBean(Oportunidad.class)); System.out.println("&&- ENVIA LISTA [OBRA DE OPORTUNIDAD] FULL -&&"); return queryObject.list(); } catch (NullPointerException n) { System.out.println("%-%-Exception Null-%-% : " + n); throw n; } catch (Exception e) { System.out.println("%-%-Exception QUERY-%-% : " + e); throw new RuntimeException(e); } }
From source file:net.firejack.platform.core.store.BaseStore.java
License:Apache License
@Transactional(readOnly = true) protected List<E> findByQuery(final Integer offset, final Integer limit, final String queryStr, final Map queryParams, final ResultTransformer transformer) { return getHibernateTemplate().execute(new HibernateCallback<List<E>>() { public List<E> doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.createQuery(queryStr); if (offset != null && offset > -1) { query.setFirstResult(offset); }//from w w w .j a v a2 s. c o m if (limit != null && limit > -1) { query.setMaxResults(limit); } query.setProperties(queryParams); query.setResultTransformer(transformer); return query.list(); } }); }
From source file:onl.netfishers.netshot.RestService.java
License:Open Source License
/** * Search devices./*from w w w .j a v a2s. com*/ * * @param request the request * @param criteria the criteria * @return the rs search results * @throws WebApplicationException the web application exception */ @POST @Path("devices/search") @RolesAllowed("readonly") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public RsSearchResults searchDevices(RsSearchCriteria criteria) throws WebApplicationException { logger.debug("REST request, search devices, query '{}', driver '{}'.", criteria.getQuery(), criteria.getDriver()); DeviceDriver driver = DeviceDriver.getDriverByName(criteria.getDriver()); try { Finder finder = new Finder(criteria.getQuery(), driver); Session session = Database.getSession(); try { Query query = session.createQuery(DEVICELIST_BASEQUERY + finder.getHql()); finder.setVariables(query); @SuppressWarnings("unchecked") List<RsLightDevice> devices = query .setResultTransformer(Transformers.aliasToBean(RsLightDevice.class)).list(); RsSearchResults results = new RsSearchResults(); results.setDevices(devices); results.setQuery(finder.getFormattedQuery()); return results; } catch (HibernateException e) { logger.error("Error while searching for the devices.", e); throw new NetshotBadRequestException("Unable to fetch the devices", NetshotBadRequestException.NETSHOT_DATABASE_ACCESS_ERROR); } finally { session.close(); } } catch (FinderParseException e) { logger.warn("User's query is invalid.", e); throw new NetshotBadRequestException("Invalid search string. " + e.getMessage(), NetshotBadRequestException.NETSHOT_INVALID_SEARCH_STRING); } }