Search code examples
javasqlhibernateseamhibernate-filters

Hibernate Filter with seam


I tried to use the hibernate filters with seam. However it thrown below exception

17:09:37,154 ERROR [STDERR] org.hibernate.HibernateException: No such filter configured [contributorTypeFilter]
        at org.hibernate.impl.SessionFactoryImpl.getFilterDefinition(SessionFactoryImpl.java:965)
        at org.hibernate.impl.SessionImpl.enableFilter(SessionImpl.java:1032)
        at org.jboss.seam.persistence.HibernateSessionProxy.enableFilter(HibernateSessionProxy.java:133)

Entity

  @OneToMany(cascade = CascadeType.ALL, mappedBy = "wfEntity")
  @OrderBy(value="orderNum")
  @JoinTable
  @FilterJoinTable(name  = "ccTypeFilter", condition  = "'CC' == WF_TYPE")
  private List<WFContEO> wfCCRoles;

  @OneToMany(cascade = CascadeType.ALL, mappedBy = "wfEntity")
  @OrderBy(value="orderNum")
  @JoinTable
  @FilterJoinTable(name  = "contTypeFilter", condition  = "'CONT' == WF_TYPE")
  private List<WFContEO> wfConts;

DAOImpl

public EntityEO findById(Long id) {
    getSession().enableFilter("contTypeFilter");
    getSession().enableFilter("ccTypeFilter");
    return (EntityEO) getSession().
          createCriteria(EntityEO.class).                                 createCriteria("wf").add(Restrictions.idEq(wfId)).uniqueResult();
  }

It throws error when enabling filter. Is there are any documentation available for How to use FilterJoinTable? Any XML configuration is required?


Solution

  • Exception is not thrown, when i remove @JoinTable.