List of usage examples for org.hibernate Query setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(String name, String val)
From source file:AdminSystemClasses.AtmDB.java
public static List<BankTransaction> viewChecks(DepositedChecks dep) throws Exception { Session sf = DB.getSession();//from w w w .j a v a 2 s . c om Transaction tx = sf.beginTransaction(); Query q = sf.createQuery( "from bank.BankTransaction bt where atmid = ? and description =? and checknumber is not null"); q.setParameter(0, dep.getAtmId()); q.setString(1, "deposit"); List<BankTransaction> bt = q.list(); return bt; }
From source file:alma.acs.commandcenter.serviceshelper.TMCDBServicesHelper.java
License:Open Source License
/** * Queries the TMCDB and return the list of services to start for the * passed configuration name.//w w w. j a v a2s .c o m * * @param configurationName The not <code>null</code> and not empty name of the configuration * @return The not <code>null</code> list of services to start for the passed configuration * @throws HibernateException In case of error getting data from the TMCDB */ @SuppressWarnings("rawtypes") public List<AcsServiceToStart> getServicesList(String configurationName) throws HibernateException { if (configurationName == null || configurationName.isEmpty()) { throw new IllegalArgumentException("Invalid null or empty name of configuration"); } logger.log(AcsLogLevel.DEBUG, "Getting the list of services from TMCDB and configuration " + configurationName); Query query = session.createSQLQuery(sqlQuery); query.setString(namedParameterName, configurationName); List svcs = query.list(); List<AcsServiceToStart> ret = new ArrayList<TMCDBServicesHelper.AcsServiceToStart>(); if (svcs != null) { AcsLogLevel lvl = (svcs.size() == 0) ? AcsLogLevel.WARNING : AcsLogLevel.DEBUG; logger.log(lvl, "Got " + svcs.size() + " services from TMCDB"); for (Object s : svcs) { ret.add(AcsServiceToStart.instanceFromDBRow((Object[]) s)); } } else { logger.log(AcsLogLevel.WARNING, "Got a NULL list of services from TMCDB"); } return ret; }
From source file:ar.com.zauber.commons.web.cache.impl.repo.hibernate.HibernateLastModifiedRepository.java
License:Apache License
/** @see LastModifiedRepository#clearTimestamp(EntityKey) */ @Transactional//from w w w. jav a2s. c om public final void clearTimestamp(final StringEntityKey key) { Validate.notNull(key); Query query = this.sessionFactory.getCurrentSession().getNamedQuery("lastModified.deleteForEntity"); query.setString("entityKey", key.getAsString()); query.executeUpdate(); }
From source file:ar.com.zauber.commons.web.cache.impl.repo.hibernate.HibernateLastModifiedRepository.java
License:Apache License
/** @see LastModifiedRepository#getTimestamp(EntityKey) */ @Transactional(readOnly = true)// w ww .j av a 2s .co m public final Long getTimestamp(final StringEntityKey key) { Validate.notNull(key); Query query = this.sessionFactory.getCurrentSession().getNamedQuery("lastModified.timestampForEntity"); query.setString("entityKey", key.getAsString()); return (Long) query.uniqueResult(); }
From source file:ar.com.zauber.commons.web.cache.impl.repo.hibernate.HibernateLastModifiedRepository.java
License:Apache License
/** @see LastModifiedRepository#updateTimestamp(EntityKey, Date) */ @Transactional//w w w.j a va 2s . c o m public final void updateTimestamp(final StringEntityKey key, final Date timestamp) { Validate.notNull(key); Validate.notNull(timestamp); Query query = this.sessionFactory.getCurrentSession().getNamedQuery("lastModified.updateForEntity"); query.setString("entityKey", key.getAsString()); query.setTimestamp("timestamp", timestamp); int updatedEntities = query.executeUpdate(); // create record if no one exist if (updatedEntities == 0) { this.sessionFactory.getCurrentSession().save(new LastModifiedRecord(timestamp, key.getAsString())); } }
From source file:aseguradora.HospitalVentana.java
private void buscarHospital(String nombre) { Session session = sesion.openSession(); Hospital hos;/* w w w.j av a 2 s . c o m*/ Query cons = session.createQuery("from pojo.Hospital as hos " + "where upper(hos.NH) LIKE ?"); cons.setString(0, "%" + nombre.toUpperCase() + "%"); List<Hospital> lista = cons.list(); DefaultTableModel model = (DefaultTableModel) tablaHospital.getModel(); if (!lista.isEmpty()) { model.getDataVector().removeAllElements(); model.fireTableDataChanged(); Iterator<Hospital> iter = lista.iterator(); while (iter.hasNext()) { hos = (Hospital) iter.next(); Hibernate.initialize(hos.getCodH()); Vector row = new Vector(); row.add(hos.getCodH()); row.add(hos.getNH()); row.add(hos.getNumC()); model.addRow(row); } tablaHospital.setModel(model); session.close(); } else { model.getDataVector().removeAllElements(); model.fireTableDataChanged(); JOptionPane.showMessageDialog(null, "No hay resultados para su bsqueda", "Informacin", JOptionPane.ERROR_MESSAGE); cargarHospital(); } }
From source file:aseguradora.MedicoVentana.java
private void buscarMedico(String nombre) { Session session = sesion.openSession(); Medico me;//from ww w . ja va 2s . com Query cons = session.createQuery("from pojo.Medico as me " + "where upper(me.NM) LIKE ?"); cons.setString(0, "%" + nombre.toUpperCase() + "%"); List<Medico> lista = cons.list(); DefaultTableModel model = (DefaultTableModel) tablaMedico.getModel(); if (!lista.isEmpty()) { model.getDataVector().removeAllElements(); model.fireTableDataChanged(); Iterator<Medico> iter = lista.iterator(); while (iter.hasNext()) { me = (Medico) iter.next(); Hibernate.initialize(me.getHospital()); Vector row = new Vector(); row.add(me.getCodM()); row.add(me.getHospital().getCodH()); row.add(me.getNM()); model.addRow(row); } tablaMedico.setModel(model); session.close(); } else { model.getDataVector().removeAllElements(); model.fireTableDataChanged(); JOptionPane.showMessageDialog(null, "No hay resultados para su bsqueda", "Informacin", JOptionPane.ERROR_MESSAGE); cargarMedico(); } }
From source file:aseguradora.VistaVentana.java
private void buscarAsegurado(String nombre) { Session session = sesion.openSession(); PolizasAsegurados pa;/*from w w w . j a v a 2 s.co m*/ Query cons = session.createQuery("from pojo.PolizasAsegurados as pa " + "where upper(pa.id.na) LIKE ?"); cons.setString(0, "%" + nombre.toUpperCase() + "%"); List<PolizasAsegurados> lista = cons.list(); DefaultTableModel model = (DefaultTableModel) tablaVista.getModel(); if (!lista.isEmpty()) { model.getDataVector().removeAllElements(); model.fireTableDataChanged(); Iterator<PolizasAsegurados> iter = lista.iterator(); while (iter.hasNext()) { pa = (PolizasAsegurados) iter.next(); Hibernate.initialize(pa.getId()); Vector row = new Vector(); row.add(pa.getId().getCodP()); row.add(pa.getId().getDatosP()); row.add(pa.getId().getNum()); row.add(pa.getId().getNa()); row.add(formatDate(pa.getId().getFn().toString())); model.addRow(row); } tablaVista.setModel(model); session.close(); } else { model.getDataVector().removeAllElements(); model.fireTableDataChanged(); JOptionPane.showMessageDialog(null, "No hay resultados para su bsqueda", "Informacin", JOptionPane.ERROR_MESSAGE); cargarVista(); } }
From source file:au.com.nicta.ct.db.CtKeyValueProperties.java
License:Open Source License
public static Query queryLike(String key, Session s) { String hql = " FROM CtProperties p WHERE p.name LIKE ?"; Query q = s.createQuery(hql); q.setString(0, key); return q;/*from w w w. j a v a 2 s. co m*/ }
From source file:au.com.nicta.ct.db.CtKeyValueProperties.java
License:Open Source License
public static Query query(String key, Session s) { String hql = " FROM CtProperties p WHERE p.name = ?"; Query q = s.createQuery(hql); q.setString(0, key); return q;//from www .jav a 2 s . co m }