Query Dsl NumberPath as operation not working

DSL query NumberPath as an operation does not work. below is the code

    BooleanBuilder whereClause = new BooleanBuilder();
    if(columnType!=null && columnType.equalsIgnoreCase("Long")){
                Number searchNumb= (Number)filterMap.get("searchText");
                Long searchText=searchNumb.longValue();
                NumberPath<Long> longColumn = 
                Expressions.numberPath(Long.class,query,searchType);
                whereClause.and( longColumn.like("%"+searchText+"%") );
    }
    return logRepository.findAll(whereClause, pageable);

      

below is the generated sql log

017-05-15 10:14:31.007 TRACE 11396 --- [           main] o.h.engine.query.spi.HQLQueryPlan        : Find: select commonLog
from CommonLog commonLog
where str(commonLog.processId) like ?1 escape '!'
2017-05-15 10:14:31.007 TRACE 11396 --- [           main] o.hibernate.engine.spi.QueryParameters   : Named parameters: {1=%164%}
2017-05-15 10:14:31.022 DEBUG 11396 --- [           main] org.hibernate.SQL                        : select commonlog0_.id as id1_1_, commonlog0_.imei as imei2_1_, commonlog0_.log_date as log_date3_1_, commonlog0_.process_id as process_4_1_ from common_log commonlog0_ where cast(commonlog0_.process_id as varchar) like ? escape '!' limit ? offset ?
Hibernate: select commonlog0_.id as id1_1_, commonlog0_.imei as imei2_1_, commonlog0_.log_date as log_date3_1_, commonlog0_.process_id as process_4_1_ from common_log commonlog0_ where cast(commonlog0_.process_id as varchar) like ? escape '!' limit ? offset ?
2017-05-15 10:14:31.022 TRACE 11396 --- [           main] o.h.r.j.i.ResourceRegistryStandardImpl   : Registering statement [org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy[Proxy=1192555591; Query=select commonlog0_.id as id1_1_, commonlog0_.imei as imei2_1_, commonlog0_.log_date as log_date3_1_, commonlog0_.process_id as process_4_1_ from common_log commonlog0_ where cast(commonlog0_.process_id as varchar) like ? escape '!' limit ? offset ?; Delegate=select commonlog0_.id as id1_1_, commonlog0_.imei as imei2_1_, commonlog0_.log_date as log_date3_1_, commonlog0_.process_id as process_4_1_ from common_log commonlog0_ where cast(commonlog0_.process_id as varchar) like ? escape '!' limit ? offset ?]]
2017-05-15 10:14:31.022 TRACE 11396 --- [           main] o.h.e.jdbc.internal.JdbcCoordinatorImpl  : Registering last query statement [org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy[Proxy=1192555591; Query=select commonlog0_.id as id1_1_, commonlog0_.imei as imei2_1_, commonlog0_.log_date as log_date3_1_, commonlog0_.process_id as process_4_1_ from common_log commonlog0_ where cast(commonlog0_.process_id as varchar) like ? escape '!' limit ? offset ?; Delegate=select commonlog0_.id as id1_1_, commonlog0_.imei as imei2_1_, commonlog0_.log_date as log_date3_1_, commonlog0_.process_id as process_4_1_ from common_log commonlog0_ where cast(commonlog0_.process_id as varchar) like ? escape '!' limit ? offset ?]]
2017-05-15 10:14:31.038 TRACE 11396 --- [           main] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [%164%]

      

but when I run the generated sql with the binding value on PGAdmin it gives the result. Below sql I was running PgAdmin.

select count(commonlog0_.id) as col_0_0_ from common_log commonlog0_ where 
 cast(commonlog0_.process_id as varchar) like '%164%' escape '!'

      

+3


source to share





All Articles