List of usage examples for org.hibernate Session enableFilter
Filter enableFilter(String filterName);
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.HibernateDaoSupport.java
License:Open Source License
public Session getSessionReadOnly() { Session currentSession = null; try {/* w ww . j a v a2 s . co m*/ currentSession = getSessionFactoryReadOnly().getCurrentSession(); } catch (Exception e) { currentSession = getSessionFactoryReadOnly().openSession(); } currentSession.enableFilter("customFieldFilter").setParameterList("customFieldFilterParam", Constants.customFieldsKey); return currentSession; }
From source file:org.geoserver.taskmanager.data.impl.TaskManagerDaoImpl.java
License:Open Source License
public final Session getSession() { Session session = sf.getCurrentSession(); session.enableFilter("activeTaskFilter"); session.enableFilter("activeBatchFilter"); session.enableFilter("activeElementFilter"); session.enableFilter("activeTaskElementFilter"); return session; }
From source file:org.jasig.portlet.ClassifiedsPortlet.service.CategoryServiceImpl.java
License:Apache License
public List<Category> getCategory(Long id) { final String query = "from Category where ID = ? "; final Long lCategory = id; HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { org.hibernate.Filter filter = session.enableFilter("VALID_ADS"); filter.setParameter("categoryRecordFilterParam", new Date()); return session.createQuery(query).setLong(0, lCategory).list(); }/*w w w . ja v a 2 s . c om*/ }; return (List<Category>) getHibernateTemplate().execute(callback); }
From source file:org.jasig.portlet.ClassifiedsPortlet.service.HeadingServiceImpl.java
License:Apache License
public List<Heading> getHeadings() { final String query = "from Heading order by headingname "; HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { org.hibernate.Filter filter = session.enableFilter("VALID_ADS"); filter.setParameter("categoryRecordFilterParam", new Date()); return session.createQuery(query).setCacheable(true).list(); }//from ww w. j a v a 2 s .c om }; return (List<Heading>) getHibernateTemplate().execute(callback); }
From source file:org.jspresso.framework.application.backend.persistence.hibernate.HibernateBackendController.java
License:Open Source License
/** * Retrieves the current thread-bound / tx-bound Hibernate session. this is * now the preferred way to perform Hibernate operations. It relies on the * Hibernate 3.1+ {@link SessionFactory#getCurrentSession()} method. * * @return the current thread-bound / tx-bound Hibernate session. *//*w w w .j a v a 2s . c o m*/ public Session getHibernateSession() { Session currentSession; if (isUnitOfWorkActive()) { try { currentSession = getHibernateSessionFactory().getCurrentSession(); } catch (HibernateException ex) { currentSession = getNoTxSession(); } } else { currentSession = getNoTxSession(); } if (currentSession != noTxSession) { // we are on a transactional session. currentSession.setFlushMode(getDefaultTxFlushMode()); } configureHibernateGlobalFilter(currentSession.enableFilter(JSPRESSO_SESSION_GLOBALS)); return currentSession; }
From source file:org.openeos.erp.core.ui.internal.ClientFilterProvider.java
License:Apache License
public void enableFilter(Session session) { Client client = (Client) sessionObjectsService .getSessionObject(ClientContextObjectContributor.CONTEXT_OBJECT_CLIENT_NAME); if (client != null) { LOG.debug("New session created, enabling filter for client selection"); Filter filter = session.enableFilter(CLIENT_FILTER_NAME); filter.setParameter("client", client.getId()); List<String> organizationList = new ArrayList<String>(); for (Organization org : ((Client) session.get(Client.class, client.getId())).getOrganizations()) { organizationList.add(org.getId()); }//ww w. ja v a 2 s .c o m filter = session.enableFilter(CLIENT_ORGANIZATION_FILTER_NAME); if (organizationList.size() == 0) { organizationList.add( "NULL_EXPECT_NEVER_HAS_THIS_KEY_BECAUSE_THE_STRING_HAS_MORE_LEN THAN THE PERMITTED_KEY"); } filter.setParameterList("organizationList", organizationList); } else { LOG.debug("Client filter not enabling because client is not established"); } }
From source file:org.opennms.netmgt.dao.AuthorizationIT.java
License:Open Source License
public void enableAuthorizationFilter(final String... groupNames) { HibernateCallback<Object> cb = new HibernateCallback<Object>() { @Override//from w ww . j a va2 s .co m public Object doInHibernate(Session session) throws HibernateException, SQLException { session.enableFilter("authorizedOnly").setParameterList("userGroups", groupNames); return null; } }; ((AlarmDaoHibernate) m_alarmDao).getHibernateTemplate().execute(cb); }
From source file:org.opennms.netmgt.dao.hibernate.HibernateFilterManager.java
License:Open Source License
/** * <p>enableAuthorizationFilter</p> * * @param authorizationGroups an array of {@link java.lang.String} objects. *///from w w w .j ava 2 s . com @Override public void enableAuthorizationFilter(final String[] authorizationGroups) { m_authorizationGroups = Arrays.copyOf(authorizationGroups, authorizationGroups.length); HibernateCallback<Object> cb = new HibernateCallback<Object>() { @Override public Object doInHibernate(Session session) throws HibernateException, SQLException { session.enableFilter(AUTH_FILTER_NAME).setParameterList("userGroups", m_authorizationGroups); return null; } }; m_template.execute(cb); }
From source file:org.riotfamily.components.index.ContentFilterRequestInterceptor.java
License:Apache License
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response) throws Exception { Session session = sessionFactory.getCurrentSession(); if (session != null) { boolean live = !EditModeUtils.isPreview(request, null); session.enableFilter("contentIndex").setParameter("live", live); if (live) { session.enableFilter("publishedContent"); }// w w w .j a v a2s.co m } return true; }
From source file:org.seasar.hibernate.jpa.PersistenceUnitConfigurationTest.java
License:Apache License
public void testPackageInfoAutoDetectionTx() throws Exception { final Session session = Session.class.cast(em.getDelegate()); session.enableFilter("id_eq"); }