解决ADF+MySQL Table filter失效问题

Table filtering, aka Query by example, is a great feature of ADF tables. This feature provides filterboxes on top of a column(es).
解决ADF+MySQL Table filter失效问题 - Mu Hongdi - MuHongdi
 
and filters the data based on the values in the filterbox:
解决ADF+MySQL Table filter失效问题 - Mu Hongdi - MuHongdi
 
This works like a charm on an Oracle database, but when you use MySQL the filtering doesn’t work and actually doesn’t retrieve any data at all. As you can understand, this is not expected and definitely not wanted behaviour.
The first step in solving this behaviour was to enable logging (either via the weblogic diagnostic console or by adding -Djbo.debugoutput=console to the Java Options in the project properties Run configuration). In the log console we see that the SQL statement for this table collection / ViewObject now includes a where clause that includes the table filter value(s): ‘ WHERE ( ( (EmployeesEo.FIRST_NAME LIKE ( :vc_temp_1 || ‘%’) ) ) ) ‘. This where clause with the % appended to the variable is automatically performed by the ADF framework.
As it turned out, this concatenation of the value with the % ( :vc_temp || ‘%’ ) was the cause of our problem. This concatenation with a double pipe is a SQL92 standard. However with MySQL the concatenation is done with the  concat  function and not the double pipe. Thus this statement causes an exception somewhere in MySQL, and the result is that no data is returned.
The solution is actually quite easy because you can configure the ‘strictness’ of MySQL to the SQL standard via the SQL mode. In this case:  SET sql_mode = ‘PIPES_AS_CONCAT’ . This value can also be set in the my.cnf or my.ini files or provided at startup via the:  –sql-mode=”PIPES_AS_CONCAT”  option. Now the filtering works as expected.

按照上述方法操作,可解决此问题
——by Mu hongdi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值