0

I want to avoid warnings about raw types, but don't know how to.

import org.apache.lucene.search.Query;
import org.hibernate.search.query.dsl.QueryBuilder;
import org.hibernate.search.query.dsl.BooleanJunction;

final QueryBuilder queryBuilder = ...;
final List<Query> queries = ...;
final BooleanJunction<?> master = queryBuilder.bool();
queries.stream().filter(Objects::nonNull).forEach(master::must);
final Query q = master.createQuery();

It works with BooleanJunction<?> but I want to replace it with something more understandable.

Going through many websites I found BooleanJunction<BooleanJunction> which initiates a warning 'BooleanJunction is a raw type. References to generic type BooleanJunction should be parameterized'.

EDIT: forgot to put configuration data

<java.version>1.8</java.version>

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent -->
<version>2.5.3</version>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<hibernate.version>5.5.6.Final</hibernate.version>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-search-orm -->
<hibernate-search-orm.version>5.11.9.Final</hibernate-search-orm.version>
horvoje
  • 643
  • 6
  • 21
  • 1
    What version of Hibernate Search are you using? I cannot recreate the warning you mention when I use your code with `BooleanJunction master` (for me, that is with version 5.11). And the JavaDoc for [`QueryBuilder.bool()`](https://docs.jboss.org/hibernate/search/5.11/api/org/hibernate/search/query/dsl/QueryBuilder.html#bool--) confirms that it returns a `BooleanJunction`. – andrewJames Aug 07 '21 at 19:53
  • @andrewjames Oh, my bad. Just edited OP and added configuration that might be useful. Thanks! – horvoje Aug 08 '21 at 09:47

0 Answers0