List of usage examples for org.hibernate Session enableFilter
Filter enableFilter(String filterName);
From source file:org.sigmah.server.domain.DomainFilters.java
License:Open Source License
public static void applyDeletedFilter(EntityManager em) { org.hibernate.Session session = ((HibernateEntityManager) em).getSession(); /* Hide entities deleted by users */ session.enableFilter("hideDeleted"); }
From source file:org.sigmah.server.domain.DomainFilters.java
License:Open Source License
public static void applyVisibleFilter(User user, EntityManager em) { /* Hide entities that this user does not have permission to view */ org.hibernate.Session session = ((HibernateEntityManager) em).getSession(); Filter filter = session.enableFilter("userVisible"); filter.setParameter("currentUserId", user.getId()); }
From source file:org.springframework.orm.hibernate3.HibernateAccessor.java
License:Apache License
/** * Enable the specified filters on the given Session. * @param session the current Hibernate Session * @see #setFilterNames//w w w. ja va2 s .co m * @see org.hibernate.Session#enableFilter(String) */ protected void enableFilters(Session session) { String[] filterNames = getFilterNames(); if (filterNames != null) { for (String filterName : filterNames) { session.enableFilter(filterName); } } }
From source file:org.springframework.orm.hibernate3.HibernateTemplate.java
License:Apache License
@Override public Filter enableFilter(String filterName) throws IllegalStateException { Session session = SessionFactoryUtils.getSession(getSessionFactory(), false); Filter filter = session.getEnabledFilter(filterName); if (filter == null) { filter = session.enableFilter(filterName); }// w w w . ja va 2s .c o m return filter; }
From source file:org.springframework.orm.hibernate3.StatelessHibernateTemplate.java
License:Apache License
public Filter enableFilter(String filterName) throws IllegalStateException { Session session = SessionFactoryUtils.getSession(getSessionFactory(), false); Filter filter = session.getEnabledFilter(filterName); if (filter == null) { filter = session.enableFilter(filterName); }/*w ww . j a v a2s .co m*/ return filter; }
From source file:org.springframework.orm.hibernate4.HibernateTemplate.java
License:Apache License
@Override public Filter enableFilter(String filterName) throws IllegalStateException { Session session = getSessionFactory().getCurrentSession(); Filter filter = session.getEnabledFilter(filterName); if (filter == null) { filter = session.enableFilter(filterName); }//from www . java 2 s . c o m return filter; }
From source file:org.verinice.persistence.Dao.java
License:Open Source License
protected void enableAccessControlFilters() { SecurityContext securityContext = SecurityContextHolder.getContext(); Account account = (Account) securityContext.getAuthentication().getPrincipal(); Session session = entityManager.unwrap(Session.class); if (account.isScoped()) { session.enableFilter("scope").setParameter("scopeId", account.getScopeId()); }//from w ww .ja v a 2 s . c om if (!account.isAdmin()) { session.enableFilter("userReadAccess").setParameterList("accountGroups", account.getAccountGroups()); } }
From source file:org.vulpe.model.dao.impl.jpa.VulpeBaseDAOJPA.java
License:Open Source License
private void enableFilters() { 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.enableFilter(filterDef.name()); }//from www .j a v a2 s . co m } else { final FilterDef filterDef = getEntityClass().getAnnotation(FilterDef.class); if (filterDef != null) { final Session session = (Session) getEntityManager().getDelegate(); session.enableFilter(filterDef.name()); } } }
From source file:sernet.verinice.service.HibernateCommandService.java
License:Open Source License
/** * /* w w w . j av a2 s .c om*/ */ private void configureScopeFilter(IBaseDao dao) { if (getConfigurationService().isScopeOnly(authService.getUsername())) { final Integer userScopeId = getConfigurationService().getScopeId(authService.getUsername()); dao.executeCallback(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException, SQLException { session.enableFilter("scopeFilter").setParameter("scopeId", userScopeId); return null; } }); } else { disableScopeFilter(dao); } }
From source file:sernet.verinice.service.HibernateCommandService.java
License:Open Source License
private void setAccessFilterEnabled(boolean enable, IBaseDao dao) { if (enable) { final Object[] roles = getConfigurationService().getRoles(authService.getUsername()); dao.executeCallback(new HibernateCallback() { @Override// w w w.j a v a 2s . c o m public Object doInHibernate(Session session) throws HibernateException, SQLException { session.enableFilter("userAccessReadFilter").setParameterList("currentRoles", roles) .setParameter("readAllowed", Boolean.TRUE); return null; } }); } else { disableScopeFilter(dao); } }