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
java hibernate querydsl


source to share


No one has answered this question yet

Check out similar questions:

3486
Why Java + =, - =, * =, / = do not require casting assignment operators?
1249
How does the Java loop for each loop work?
1116
Android SDK installation not finding JDK
911
Getting the current working directory in Java
898
:: (double colon) in Java 8
877
Why doesn't RecyclerView have onItemClickListener ()?
2
JPA: deleting content of multiple objects in a cascade
1
QueryDSL throwing cannot throw property exception
0
Spring data by mac. SQL queries containing a parameter with non-latin characters return null
0
Hibernate cannot execute native SqlExceptionHelper: Invalid value "7" for parameter "parameterIndex"



All Articles
Loading...
X
Show
Funny
Dev
Pics