Getting error trying to apply operators to uuid

Issue #18 open
João Rodrigues created an issue

I am trying to apply operations to an uuid field
i implemented the beans indicated in the project but i cant pull it off kinda suck here

allways getting this error

{
    "timestamp": "2019-10-24T11:45:29.309+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "CacheLoader returned null for key funcionario.uuid.",
    "trace": "com.google.common.cache.CacheLoader$InvalidCacheLoadException: CacheLoader returned null for key funcionario.uuid.\n\tat com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2315)\n\tat com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2279)\n\tat com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2155)\n\tat com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2045)\n\tat com.google.common.cache.LocalCache.get(LocalCache.java:3953)\n\tat com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3976)\n\tat com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4960)\n\tat com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4966)\n\tat org.bitbucket.gt_tech.spring.data.querydsl.value.operators.ExpressionProviderFactory.getPredicate(ExpressionProviderFactory.java:89)\n\tat pt.airc.fun.dao.FuncionarioRepository.lambda$customize$0(FuncionarioRepository.java:28)\n\tat 

I have this stuff implemented

public interface FuncionarioRepository extends PagingAndSortingRepository<Funcionario, Long>, QuerydslPredicateExecutor<QFuncionario>, QuerydslBinderCustomizer<QFuncionario> {
    @Override
    default public void customize(QuerydslBindings bindings, QFuncionario root) {

        bindings.bind(root.uuid)
                .all((path , values) -> ExpressionProviderFactory.getPredicate(path, values));
    }
}

@Configuration
public class QueryDslValueOperatorsConfig {

    @Bean
    public FilterRegistrationBean querydslHttpRequestContextAwareServletFilter() {
        FilterRegistrationBean bean = new FilterRegistrationBean();
        bean.setFilter(new QuerydslHttpRequestContextAwareServletFilter(
                querydslHttpRequestContextAwareServletFilterMappings()));
        bean.setAsyncSupported(false);
        bean.setEnabled(true);
        bean.setName("querydslHttpRequestContextAwareServletFilter");
        bean.setUrlPatterns(Arrays.asList(new String[] { "/funcionario*" }));
        bean.setOrder(Ordered.LOWEST_PRECEDENCE);
        return bean;
    }

    private Map<String, Class<?>> querydslHttpRequestContextAwareServletFilterMappings() {
        Map<String, Class<?>> mappings = new HashMap<>();
        mappings.put("/funcionario", Funcionario.class);
        return mappings;
    }

    /**
     * Note the use of delegate ConversionService which comes handy for types like
     * java.util.Date for handling powerful searches natively with Spring data.
     * @param factory QuerydslBindingsFactory instance
     * @param conversionServiceDelegate delegate ConversionService
     * @return
     */
    @Bean
    public QuerydslPredicateArgumentResolverBeanPostProcessor querydslPredicateArgumentResolverBeanPostProcessor(
            QuerydslBindingsFactory factory) {
        return new QuerydslPredicateArgumentResolverBeanPostProcessor(factory);
    }
}

Maybe i lacking some uuid convert implementation or smth

Comments (6)

  1. João Rodrigues reporter

    can you give an hint on how to do it? i am having some problems creating the bean

    @Bean
        public ConversionService getConversionService() {
            ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
            HashSet arrayList = new HashSet();
            arrayList.add(new sdfras());
            bean.setConverters(arrayList); //add converters
            bean.afterPropertiesSet();
            return bean.getObject();
        }
    

    public class sdfras extends DefaultConversionService implements Converter<String, UUID> {
        @Override
        public UUID convert(String source) {
            System.out.println("WARN123" + source);
            return UUID.fromString(source);
        }
    }
    

    Do you think i have smth wrong?

  2. GT Tech repo owner

    conversion service appears to be correct though there are other ways to use it. Did you get past the issue? Spring conversion is a bit delayed with advanced features of this library while its eagerly processed without advanced features. Were you able to put a break point in your default converter to confirm that it does get invoked? this would be a good data point to know that is the issue in library or else with the way its configured to get used? If you can share a small sample, I can take it further.

  3. Gianluca Sabato

    I have the same problem for UUID fields. I have to exclude them while customizing the bindings. Can you fix it? I really love your lib.

  4. Log in to comment