Package org.hibernate

Examples of org.hibernate.Filter


  }

  @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);
    }
    return filter;
  }
View Full Code Here


    ordered.verify(session).disableFilter("yourFilter");
  }

  @Test
  public void testExecuteWithThreadBoundAndParameterizedFilter() {
    Filter filter = mock(Filter.class);
    given(session.enableFilter("myFilter")).willReturn(filter);
    hibernateTemplate.setFilterNames("myFilter");

    final List l = new ArrayList();
    l.add("test");
    Filter f = hibernateTemplate.enableFilter("myFilter");
    assertTrue("Correct filter", f == filter);

    InOrder ordered = inOrder(session);
    ordered.verify(session).getEnabledFilter("myFilter");
    ordered.verify(session).enableFilter("myFilter");
View Full Code Here

    ordered.verify(session).enableFilter("myFilter");
  }

  @Test
  public void testExecuteWithThreadBoundAndParameterizedExistingFilter() {
    Filter filter = mock(Filter.class);
    given(session.enableFilter("myFilter")).willReturn(filter);
    hibernateTemplate.setFilterNames("myFilter");

    final List l = new ArrayList();
    l.add("test");
    Filter f = hibernateTemplate.enableFilter("myFilter");
    assertTrue("Correct filter", f == filter);

    verify(session).getEnabledFilter("myFilter");
  }
View Full Code Here

    ordered.verify(session).disableFilter("yourFilter");
  }

  @Test
  public void testExecuteWithThreadBoundAndParameterizedFilter() {
    Filter filter = mock(Filter.class);
    given(session.isOpen()).willReturn(true);
    given(session.enableFilter("myFilter")).willReturn(filter);
    hibernateTemplate.setAllowCreate(false);
    hibernateTemplate.setFilterName("myFilter");

    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
    try {
      final List l = new ArrayList();
      l.add("test");
      Filter f = hibernateTemplate.enableFilter("myFilter");
      assertTrue("Correct filter", f == filter);
    }
    finally {
      TransactionSynchronizationManager.unbindResource(sessionFactory);
    }
View Full Code Here

    ordered.verify(session).enableFilter("myFilter");
  }

  @Test
  public void testExecuteWithThreadBoundAndParameterizedExistingFilter() {
    Filter filter = mock(Filter.class);
    given(session.isOpen()).willReturn(true);
    given(session.enableFilter("myFilter")).willReturn(filter);
    hibernateTemplate.setAllowCreate(false);
    hibernateTemplate.setFilterName("myFilter");

    TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
    try {
      final List l = new ArrayList();
      l.add("test");
      Filter f = hibernateTemplate.enableFilter("myFilter");
      assertTrue("Correct filter", f == filter);
    }
    finally {
      TransactionSynchronizationManager.unbindResource(sessionFactory);
    }
View Full Code Here

    }
  }

  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);
    }
    return filter;
  }
View Full Code Here

    }

    private static final String CONSUMER_FILTER = "Entitlement_CONSUMER_FILTER";

    public int getNoOfDependentEntitlements(String entitlementId) {
        Filter consumerFilter = disableConsumerFilter();
        Integer result = (Integer)
            currentSession().createCriteria(Entitlement.class)
                .setProjection(Projections.rowCount())
                .createCriteria("pool")
                    .createCriteria("sourceEntitlement")
View Full Code Here

     */
    private void enableIfPrevEnabled(Filter consumerFilter) {
        // if filter was previously enabled, restore it.
        if (consumerFilter != null) {
            FilterImpl filterImpl = (FilterImpl) consumerFilter;
            Filter filter = currentSession().enableFilter(CONSUMER_FILTER);
            filter.setParameter("consumer_id", filterImpl.getParameter("consumer_id"));
        }
    }
View Full Code Here

            filter.setParameter("consumer_id", filterImpl.getParameter("consumer_id"));
        }
    }

    public Filter disableConsumerFilter() {
        Filter consumerFilter = currentSession().getEnabledFilter(CONSUMER_FILTER);
        currentSession().disableFilter(CONSUMER_FILTER);
        return consumerFilter;
    }
View Full Code Here

    }
  }

  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);
    }
    return filter;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.