List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:com.jaspersoft.jasperserver.api.metadata.data.snapshot.hibernate.HibernateDataSnapshotContentsService.java
License:Open Source License
@Transactional(propagation = Propagation.MANDATORY, readOnly = false) public void deleteDataSnapshot(ExecutionContext context, final long id) { getHibernateTemplate().execute(new HibernateCallback<Void>() { public Void doInHibernate(Session session) throws HibernateException, SQLException { if (log.isDebugEnabled()) { log.debug("deleting snapshot data " + id); }//from www . j a v a 2 s. c o m // deleting via a bulk query so that we don't need to load the entity (including the data) int count = session.getNamedQuery("JIDataSnapshotContentsDeleteId").setLong("id", id) .executeUpdate(); if (log.isDebugEnabled()) { log.debug("deleted " + count + " records for snapshot " + id); } if (count > 1) { // protect against any accidents throw new JSException("Deletion of data snapshot " + id + " removed " + count + " records"); } return null; } }); }
From source file:com.jdon.persistence.hibernate.HibernateTemplate.java
License:Apache License
public List findByNamedQuery(final String queryName, final Object[] values) throws Exception { return (List) doHibernate(new HibernateCallback() { public Object execute(Session session) throws HibernateException { Query queryObject = session.getNamedQuery(queryName); prepareQuery(queryObject);//from ww w .j a v a 2 s.com if (values != null) { for (int i = 0; i < values.length; i++) { queryObject.setParameter(i, values[i]); } } return queryObject.list(); } }); }
From source file:com.jdon.persistence.hibernate.HibernateTemplate.java
License:Apache License
public List findByNamedQueryAndNamedParam(final String queryName, final String[] paramNames, final Object[] values) throws Exception { if (paramNames != null && values != null && paramNames.length != values.length) { throw new IllegalArgumentException("Length of paramNames array must match length of values array"); }/*w ww. j av a 2s . com*/ return (List) doHibernate(new HibernateCallback() { public Object execute(Session session) throws HibernateException { Query queryObject = session.getNamedQuery(queryName); prepareQuery(queryObject); if (values != null) { for (int i = 0; i < values.length; i++) { applyNamedParameterToQuery(queryObject, paramNames[i], values[i]); } } return queryObject.list(); } }); }
From source file:com.jdon.persistence.hibernate.HibernateTemplate.java
License:Apache License
public List findByNamedQueryAndValueBean(final String queryName, final Object valueBean) throws Exception { return (List) doHibernate(new HibernateCallback() { public Object execute(Session session) throws HibernateException { Query queryObject = session.getNamedQuery(queryName); prepareQuery(queryObject);/*from ww w . j a v a 2s.c o m*/ queryObject.setProperties(valueBean); return queryObject.list(); } }); }
From source file:com.knowbout.epg.entities.Credit.java
License:Apache License
public static Credit selectByValues(CreditType type, String firstName, String lastName, String roleDescription) { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("Credit.getByValues"); query.setInteger("type", type.ordinal()); query.setString("firstName", firstName); query.setString("lastName", lastName); query.setString("roleDescription", roleDescription); return (Credit) query.uniqueResult(); }
From source file:com.knowbout.epg.entities.Lineup.java
License:Apache License
/** * Get the Channel(s) for the given channel number on this lineup. * It is possible for there to be two channels for the same channel number. * If this is the case, each will have a different station and obviously only * one will be playing content at a time. This creates a time sharing situation * for that channel. 95% of the time, this does not happen, but it does for a few * channels./*from ww w .j ava 2 s. co m*/ * @param channelNumber * @return the list of channels for the given channel number. */ @SuppressWarnings("unchecked") public List<Channel> getChannel(String channelNumber) { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("Lineup.getChannels"); query.setString("lineupId", id); query.setString("channelNumber", channelNumber); List results = query.list(); List<Channel> castResults = new ArrayList<Channel>(results.size()); castResults.addAll(results); return castResults; }
From source file:com.knowbout.epg.entities.Network.java
License:Apache License
public static Network findByCallSign(String callSign) { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("Network.findByCallSign"); query.setString("callSign", callSign); query.setMaxResults(1);/*from w ww . ja v a 2 s. c o m*/ return (Network) query.uniqueResult(); }
From source file:com.knowbout.epg.entities.NetworkLineup.java
License:Apache License
public static List<NetworkLineup> selectSearchableLineups() { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("NetworkLineup.selectSearchable"); return query.list(); }
From source file:com.knowbout.epg.entities.NetworkLineup.java
License:Apache License
public static List<NetworkLineup> selectAll() { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("NetworkLineup.selectAll"); return query.list(); }
From source file:com.knowbout.epg.entities.NetworkSchedule.java
License:Apache License
public static int deleteAfter(Date date) { Session session = HibernateUtil.currentSession(); Query query = session.getNamedQuery("NetworkSchedule.deleteByDate"); query.setTimestamp("date", date); int count = query.executeUpdate(); return count; }