eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Like condition at `@Query` doesn't support parameterization

dearrudam opened this issue · comments

Which JNoSQL project the issue refers to?

JNoSQL (Core)

Bug description

Query methods like the below, with LIKE parameterized conditions, throws an org.eclipse.jnosql.communication.QueryException exception with a similar message like that: mismatched input '@name' expecting STRING when they're performed;

@Repository
public interface JavaDay extends PageableRepository<Developer, String> {
    @Query("select * from Developer where name like @name")
    Stream<Developer> whoIs(@Param("name") String name);
}

JNoSQL Version

JNoSQL 1.0.1

Steps To Reproduce

  1. Create an entity and its repository like the below:
@Entity
public class Developer {
   @Id
   private String id;
   @Column
   private String name;
   // omitting getters and setters
}

@Repository
public interface JavaDay extends PageableRepository<Developer, String> {
    @Query("select * from Developer where name like @name")
    Stream<Developer> whoIs(@Param("name") String name);
}
  1. Persist the target entity and try to execute the method annotated with @Query:
   JavaDay javaday = // omitting injection info
   Developer dev=new Developer();
   dev.setId(UUID.ramdon().toString();
   dev.setName("Maximillian Arruda");
   javaday.save(dev);

   Stream<Developer> result = javaday.whoIs("Max");
  1. An org.eclipse.jnosql.communication.QueryException exception will be thrown with a similar message like that:
    mismatched input '@name' expecting STRING

Expected Results

It's expected to return the persisted Developers where the name starts with "Max"

Code example, screenshot, or link to a repository

image