Code example for Session

Methods: createQuery

0
	public void deleteById(Long id) {
		if (id == null) {
			return; 
		} 
		Session session = getSession();
		Object item = session.createQuery("from UserSubstitution where id = :id")
				.setParameter("id", id)
				.uniqueResult();
		if (item != null) { 
			delete((UserSubstitution)item); 
		} 
	} 
 
	@Override 
	public List<UserSubstitution> findAllEagerUserFetch() {
		DetachedCriteria criteria = getDetachedCriteria()
				.setFetchMode(UserSubstitution._USER, FetchMode.JOIN)
				.setFetchMode(UserSubstitution._USER_SUBSTITUTE, FetchMode.JOIN);
		return findByCriteria(criteria);
	}