2

I am using Springboot 2.1.4 with spring-boot-data-couchbase. I am trying to make a paginated query using like operator for one property.

These are the artifacts:

  • Repository
@N1qlPrimaryIndexed
@ViewIndexed(designDoc = "LogicalResource", viewName = "all")
public interface LogicalResourceRepository extends CouchbasePagingAndSortingRepository<LogicalResource, String>
{
    Page<LogicalResource> findByValueLike(String value, Pageable pageable);    
}
  • Service
@Service
public class LogicalResourceService extends BaseCrudService<LogicalResource> 
{

    @Autowired
    LogicalResourceRepository logicalResourceRepository;

    @Override
    public EntityListSlice<LogicalResource> simpleSearch(Integer page, Integer size, String search) 
    {   
        Page<LogicalResource> pageData = this.logicalResourceRepository.findByValueLike("%"+search+"%", PageRequest.of(page, size));

        long totalElements = pageData.getTotalElements();
        List<LogicalResource> data = pageData.getContent();

        return new EntityListSlice<LogicalResource>()
                .setPage(page)
                .setSize(size)
                .setTotal(totalElements)
                .setEntities(data);
    }

}

The class EntityListSlice is just a pojo to handle the data.

When the mehthod is invoked, the follow exception is thrown:

Unable to execute query due to the following n1ql errors: ↵{"msg":"Panic: runtime error: invalid memory address or nil pointer dereference","code":5001}

¿Is there a better way to make this kind of queries? ¿How can I handle the exception?

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
Herber230
  • 141
  • 1
  • 12
  • Hi! I'm not familiar with this error, can you post your entity? Nothing seems wrong with your code at first, the only issue is that "value" is a reserved word, so I guess that is the error. – deniswsrosa May 14 '20 at 09:44
  • 1
    I think the error is about the property called "value" about you said. I made a test with another property and everything is ok. ¿Is there another way to make the query? ¿Do you need to see the entity? – Herber230 May 15 '20 at 22:56
  • No worries, as long as you have solved the problem, that is ok. – deniswsrosa May 17 '20 at 17:06

0 Answers0