Programmatically adding FilterDefinition

Hello

Is it possible in version 6 to add FilterDefinition without @FilrterDef annotation?

I tried MetadataContributor, but it is not working: not seen in the list of classLoaderService

import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataContributor;
import org.jboss.jandex.IndexView;
import org.kohsuke.MetaInfServices;
import org.springframework.stereotype.Component;

@Component
public class AddFilterContributor implements MetadataContributor {
    @Override
    public void contribute(InFlightMetadataCollector inFlightMetadataCollector, IndexView indexView) {
               inFlightMetadataCollector.addFilterDefinition(new FilterDefinition(...));
    }
}

Also. Not sure it is important: AddFilterContributor is still not created at the moment of calling MetadataBuildingProcess#complete

Mikl

Also tried to add file
src\main\resources\META-INF\services\org.hibernate.boot.spi.MetadataContributor
with fully qualified name

the same result :frowning:

pls help me

My bad. it is working!

  1. @Component is not necessary
  2. org.hibernate.boot.spi.MetadataContributor file in resources is mondatory