I'm using Micronaut Data version 1.0.2.
Given the following JPA entity class:
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String code;
private String name;
private String fullName;
}
I can create full-text search query with the following method of PageableRepository
:
@Repository
public interface ProductRepository extends PageableRepository<Product, Long> {
Slice<Product> findByCodeLikeOrNameLikeOrFullNameLike(
String code, String name, String fullName, Pageable pageable);
}
However, I have a problem to add one more criterion for the name
property. What I want to achieve is equivalent to the following SQL:
select * from product
where code like '%search%'
or (name like '%search%' and name not like '%-%')
or full_name like '%search%'
I tested the following ways:
Slice<Product> findByCodeLikeOrNameLikeAndNotLikeOrFullNameLike
Slice<Product> findByCodeLikeOrNameLikeAndNotContainsOrFullNameLike
Slice<Product> findByCodeLikeOrNameLikeAndNameNotLikeOrFullNameLike
Slice<Product> findByCodeLikeOrNameLikeAndNameNotContainsOrFullNameLike
Any idea how to make it works?
Thank in advanced.