Jill
Jill

Reputation: 333

Spring JPA findByColumnNameLike not working

I have a method -> findByfileNameLike(fileName,1, pageable) and its declaration in a repository that extends JPA Repository is

@Query(value = QUERY)
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
@LogExecutionTime
Page<BatchDTO> findByfileNameLike(String 
              fileName,@Param("departmentId")Integer departmentId, Pageable pageable)

Query is Select new DTO(bdm.id.batch.status) from Table bdm where bdm.id.departmentId =:departmentId and bdm.id.batch.status <> 7";

I want to filter the query by the column fileName.I have read to give the method name as given according to the doc of spring data jpa.But its not working. Where and how will i give the fileName to be filtered?Should it be first parameter in the method?

Upvotes: 1

Views: 117

Answers (1)

Deni Simon
Deni Simon

Reputation: 161

Once you specify a query using the annotation @Query, Spring data jpa will not automatically create a query for you based on the method name and it will rely on the query provided by using the annotation. The method findByfileNameLike will not make any difference here as a query is provided explicitly. Hope that answers your question

Upvotes: 1

Related Questions