NamedQuery with Collection as Parameter

2

I'm using JPA NamedQuery to create a DTO. And in my Query I have as condition an IN and as parameter IN has values with white spaces in the middle. (Ex: 9292-929). and these values with whitespace, returns nothing. Only values with no space.

@Query("SELECT NEW br.com.dto.LancamantoDto(m.id, r.id) \n" +
        "FROM Lancamento l \n" +
        "WHERE l.seuNumero IN  (:seuNumero) \n" +
        "AND   l.data       =   :data")
List<LancamentoDto> findAllBySeuNumeroAndData(@Param("seuNumero")List<String> seuNumero, @Param("data")LocalDate data);
    
asked by anonymous 05.01.2015 / 17:50

1 answer

1

The correct syntax (JPQL Snippet) for IN with Collections should be written without parentheses:

Query("SELECT NEW br.com.dto.LancamantoDto(m.id, r.id) \n" +
        "FROM Lancamento l \n" +
        "WHERE l.seuNumero IN  :seuNumero \n" +
        "AND   l.data       =   :data")

There was a bug in hibernate a while ago, it seems that it has reappeared in a new version (4.3 ).

    
17.06.2015 / 06:18