List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:com.opengamma.masterdb.batch.DbBatchWriter.java
License:Open Source License
protected FunctionUniqueId getFunctionUniqueIdInTransaction(final String uniqueId) { FunctionUniqueId functionUniqueId = getHibernateTemplate() .execute(new HibernateCallback<FunctionUniqueId>() { @Override/* w ww . jav a 2 s.c o m*/ public FunctionUniqueId doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery("FunctionUniqueId.one.byUniqueId"); query.setString("uniqueId", uniqueId); return (FunctionUniqueId) query.uniqueResult(); } }); if (functionUniqueId == null) { functionUniqueId = new FunctionUniqueId(); functionUniqueId.setUniqueId(uniqueId); getHibernateTemplate().save(functionUniqueId); getHibernateTemplate().flush(); } return functionUniqueId; }
From source file:com.opengamma.security.user.HibernateUserManager.java
License:Open Source License
@Override public User getUser(final String username) { ArgumentChecker.notNull(username, "User name"); return _hibernateTemplate.execute(new HibernateCallback<User>() { @Override/*from w w w. j a v a 2s . c o m*/ public User doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery("User.one.byUsername"); query.setString("username", username); return (User) query.uniqueResult(); } }); }
From source file:com.opengamma.security.user.HibernateUserManager.java
License:Open Source License
@Override public UserGroup getUserGroup(final String name) { ArgumentChecker.notNull(name, "Group name"); return _hibernateTemplate.execute(new HibernateCallback<UserGroup>() { @Override/*from ww w.ja va2s . co m*/ public UserGroup doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery("UserGroup.one.byName"); query.setString("name", name); return (UserGroup) query.uniqueResult(); } }); }
From source file:com.opengamma.security.user.HibernateUserManager.java
License:Open Source License
@Override public Authority getAuthority(final String regex) { ArgumentChecker.notNull(regex, "Authority"); return _hibernateTemplate.execute(new HibernateCallback<Authority>() { @Override/* w w w .j a va2 s . c om*/ public Authority doInHibernate(Session session) throws HibernateException, SQLException { Query query = session.getNamedQuery("Authority.one.byAuthorityRegex"); query.setString("regex", regex); return (Authority) query.uniqueResult(); } }); }
From source file:com.painiu.core.dao.hibernate.PhotoDAOHibernate.java
License:Open Source License
public List getInterestingnessPhotoIdsGroupByDate(final Date fromDate, final Date toDate, final int limit) { return (List) getReadOnlyHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Query queryObject = session.getNamedQuery("getPhotoInterestingGroupByDate"); queryObject.setInteger("limit", limit); queryObject.setTimestamp("fromDate", fromDate); queryObject.setTimestamp("toDate", toDate); return queryObject.list(); }//from w ww . j av a 2 s . c o m }); }
From source file:com.pos.spatobiz.app.dao.KaryawanDaoImpl.java
License:Apache License
@Transactional(readOnly = true) public Karyawan getKaryawan(final Long id) throws SpatoBizException { try {/*from www. j ava 2 s . c o m*/ return (Karyawan) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.getNamedQuery("Karyawan.getById").setParameter("id", id).uniqueResult(); } }); } catch (Throwable t) { throw new SpatoBizException(t.getMessage()); } }
From source file:com.pos.spatobiz.app.dao.KaryawanDaoImpl.java
License:Apache License
@Transactional(readOnly = true) public Karyawan getKaryawan(final String kode) throws SpatoBizException { try {/*from w ww .j a v a 2 s.c om*/ return (Karyawan) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.getNamedQuery("Karyawan.getByKode").setParameter("kode", kode).setMaxResults(1) .uniqueResult(); } }); } catch (Throwable t) { throw new SpatoBizException(t.getMessage()); } }
From source file:com.pos.spatobiz.app.dao.PelangganDaoImpl.java
License:Apache License
@Transactional(readOnly = true) public Pelanggan getPelanggan(final Long id) throws SpatoBizException { try {//from w ww . j a va2 s .co m return (Pelanggan) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.getNamedQuery("Pelanggan.getById").setParameter("id", id).uniqueResult(); } }); } catch (Throwable t) { throw new SpatoBizException(t.getMessage()); } }
From source file:com.pos.spatobiz.app.dao.PemasokDaoImpl.java
License:Apache License
@Transactional(readOnly = true) public Pemasok getSupplier(final Long id) throws SpatoBizException { try {/* w w w . j a v a 2 s . c o m*/ return (Pemasok) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.getNamedQuery("Pemasok.getById").setParameter("id", id).uniqueResult(); } }); } catch (Throwable t) { throw new SpatoBizException(t.getMessage()); } }