List of usage examples for org.hibernate Session disableFilter
void disableFilter(String filterName);
From source file:org.sigmah.server.endpoint.gwtrpc.handler.GetRemindersHandler.java
License:Open Source License
@Override public CommandResult execute(GetReminders cmd, User user) throws CommandException { final ArrayList<ReminderDTO> dtos = new ArrayList<ReminderDTO>(); final Session session = ((HibernateEntityManager) em).getSession(); session.disableFilter("userVisible"); // Use a set to be avoid duplicated entries. final HashSet<OrgUnit> units = new HashSet<OrgUnit>(); // Crawl the org units hierarchy from the user root org unit. GetProjectHandler.crawlUnits(user.getOrgUnitWithProfiles().getOrgUnit(), units, false); // Retrieves all the corresponding org units. for (final OrgUnit unit : units) { // Builds and executes the query. final Query query = em.createQuery( "SELECT p.remindersList.reminders FROM Project p WHERE :unit MEMBER OF p.partners"); query.setParameter("unit", unit); final List<Reminder> reminders = (List<Reminder>) query.getResultList(); for (final Reminder reminder : reminders) { if (reminder.getCompletionDate() == null) {// Not completed only ReminderDTO reminderDTO = mapper.map(reminder, ReminderDTO.class); reminderDTO.setDeleted(reminder.isDeleted()); dtos.add(reminderDTO);//from ww w. ja va 2 s . co m } } } final RemindersResultList result = new RemindersResultList(); result.setList(dtos); return result; }
From source file:org.springframework.orm.hibernate3.HibernateAccessor.java
License:Apache License
/** * Disable the specified filters on the given Session. * @param session the current Hibernate Session * @see #setFilterNames// w ww . ja v a2 s. c o m * @see org.hibernate.Session#disableFilter(String) */ protected void disableFilters(Session session) { String[] filterNames = getFilterNames(); if (filterNames != null) { for (String filterName : filterNames) { session.disableFilter(filterName); } } }
From source file:org.vulpe.model.dao.impl.jpa.VulpeBaseDAOJPA.java
License:Open Source License
private void disableFilters() { final FilterDefs filterDefs = getEntityClass().getAnnotation(FilterDefs.class); if (filterDefs != null && filterDefs.value().length > 0) { final Session session = (Session) getEntityManager().getDelegate(); for (final FilterDef filterDef : filterDefs.value()) { session.disableFilter(filterDef.name()); }//w w w. j a v a2s . c o m } else { final FilterDef filterDef = getEntityClass().getAnnotation(FilterDef.class); if (filterDef != null) { final Session session = (Session) getEntityManager().getDelegate(); session.disableFilter(filterDef.name()); } } }
From source file:sernet.verinice.hibernate.SecureTreeElementDao.java
License:Open Source License
private void setScopeFilterEnabled(boolean enable) { if (getConfigurationService().isScopeOnly(authService.getUsername()) && enable) { final Integer userScopeId = getConfigurationService().getScopeId(authService.getUsername()); getHibernateTemplate().enableFilter("scopeFilter").setParameter("scopeId", userScopeId); } else {/*from ww w . j a va 2 s .c om*/ getHibernateTemplate().execute(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException, SQLException { session.disableFilter("scopeFilter"); return null; } }); } }
From source file:sernet.verinice.hibernate.SecureTreeElementDao.java
License:Open Source License
private void setAccessFilterEnabled(boolean enable) { if (enable) { final Object[] roles = getConfigurationService().getRoles(authService.getUsername()); getHibernateTemplate().enableFilter("userAccessReadFilter").setParameterList("currentRoles", roles) .setParameter("readAllowed", Boolean.TRUE); } else {//www . java 2 s .c om getHibernateTemplate().execute(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException, SQLException { session.disableFilter("userAccessReadFilter"); return null; } }); } }
From source file:sernet.verinice.service.HibernateCommandService.java
License:Open Source License
private void disableScopeFilter(IBaseDao dao) { dao.executeCallback(new HibernateCallback() { @Override/*from w w w .java2s . c om*/ public Object doInHibernate(Session session) throws HibernateException, SQLException { session.disableFilter("scopeFilter"); return null; } }); }