[Seasar-user:16451] 【S2JDBC】タイプセーフのLIKE 〜 ESCAPE演算子を使用時に例外が発生

Takeshi Motegi [E-MAIL ADDRESS DELETED]
2008年 12月 4日 (木) 20:07:19 JST


茂木です。

S2JDBCのタイプセーフを色々と試しているのですが、ちょっとあれっ?て
例外が発生しました。

以下の環境で、
・sa-struts-1.0.4-sp2.jar
・s2-framework-2.4.32.jar
・s2-extension-2.4.32.jar
・s2-tiger-2.4.32.jar
・s2jdbc-gen-0.9.3.jar
・hsqldb.jar(1.8.0.10)
・HSQLDB使用テーブル → HSQLDBのファイルを添付しました。

s2jdbc-genでgen-entityをターゲットにしてソースを自動生成しました。そして、
EmployeeServiceクラスに、タイプセーフのLIKE 〜 ESCAPE演算子を使用する
以下のメソッドを追加して実行しました。

public List<Employee> findByName() {
    return select().where( like(name(), "$_AbelCain", 
"$") ).getResultList();
}

ところが、↓のような例外が発生してしまいました。内容を見るとプレースホルダーに 

パラメータが渡っていないままにSQLを実行してしまっているようですが、使い方が何か
まずいのでしょうか?

致命的: サーブレット default のServlet.service()が例外を投げました
java.sql.SQLException: Invalid escape character in statement [select T1_.ID 
as C1_, T1_.NAME as C2_, T1_.JOB_TYPE as C3_, T1_.SALARY as C4_, 
T1_.DEPARTMENT_ID as C5_, T1_.ADDRESS_ID as C6_, T1_.VERSION as C7_ from 
EMPLOYEE T1_ where (T1_.NAME like ? escape ?)]
 at org.hsqldb.jdbc.Util.throwError(Unknown Source)
 at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
 at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
 at 
org.seasar.extension.dbcp.impl.ConnectionWrapperImpl.prepareStatement(ConnectionWrapperImpl.java:174)
 at 
org.seasar.extension.jdbc.util.ConnectionUtil.prepareStatement(ConnectionUtil.java:93)
 at 
org.seasar.extension.jdbc.manager.JdbcContextImpl.usingPreparedStatement(JdbcContextImpl.java:141)
 at 
org.seasar.extension.jdbc.query.AbstractSelect.processPreparedStatement(AbstractSelect.java:278)
 at 
org.seasar.extension.jdbc.query.AbstractSelect.processResultSet(AbstractSelect.java:407)
 at 
org.seasar.extension.jdbc.query.AbstractSelect.getResultListInternal(AbstractSelect.java:209)
 at 
org.seasar.extension.jdbc.query.AbstractSelect.getResultList(AbstractSelect.java:171)
 at tutorial.service.EmployeeService.findByName(EmployeeService.java:74)
 at 
tutorial.service.EmployeeService$$EnhancedByS2AOP$$1a68375.$$findByName$$invokeSuperMethod$$(EmployeeService$$EnhancedByS2AOP$$1a68375.java)
 at 
tutorial.service.EmployeeService$$EnhancedByS2AOP$$1a68375$$MethodInvocation$$findByName0.proceed(MethodInvocationClassGenerator.java)
 at 
org.seasar.extension.tx.DefaultTransactionCallback.execute(DefaultTransactionCallback.java:58)
 at 
org.seasar.extension.tx.adapter.JTATransactionManagerAdapter.required(JTATransactionManagerAdapter.java:65)
 at 
org.seasar.extension.tx.RequiredInterceptor.invoke(RequiredInterceptor.java:41)
 at 
tutorial.service.EmployeeService$$EnhancedByS2AOP$$1a68375$$MethodInvocation$$findByName0.proceed(MethodInvocationClassGenerator.java)
 at 
org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
 at 
tutorial.service.EmployeeService$$EnhancedByS2AOP$$1a68375$$MethodInvocation$$findByName0.proceed(MethodInvocationClassGenerator.java)
 at 
tutorial.service.EmployeeService$$EnhancedByS2AOP$$1a68375.findByName(EmployeeService$$EnhancedByS2AOP$$1a68375.java)
 at tutorial.action.SearchAction.search(SearchAction.java:34)
 at 
tutorial.action.SearchAction$$EnhancedByS2AOP$$a3defe.$$search$$invokeSuperMethod$$(SearchAction$$EnhancedByS2AOP$$a3defe.java)
 at 
tutorial.action.SearchAction$$EnhancedByS2AOP$$a3defe$$MethodInvocation$$search0.proceed(MethodInvocationClassGenerator.java)
 at 
org.seasar.extension.tx.DefaultTransactionCallback.execute(DefaultTransactionCallback.java:58)
 at 
org.seasar.extension.tx.adapter.JTATransactionManagerAdapter.required(JTATransactionManagerAdapter.java:65)
 at 
org.seasar.extension.tx.RequiredInterceptor.invoke(RequiredInterceptor.java:41)
 at 
tutorial.action.SearchAction$$EnhancedByS2AOP$$a3defe$$MethodInvocation$$search0.proceed(MethodInvocationClassGenerator.java)
 at 
org.seasar.framework.aop.interceptors.ThrowsInterceptor.invoke(ThrowsInterceptor.java:79)
 at 
tutorial.action.SearchAction$$EnhancedByS2AOP$$a3defe$$MethodInvocation$$search0.proceed(MethodInvocationClassGenerator.java)
 at 
org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:73)
 at 
tutorial.action.SearchAction$$EnhancedByS2AOP$$a3defe$$MethodInvocation$$search0.proceed(MethodInvocationClassGenerator.java)
 at 
tutorial.action.SearchAction$$EnhancedByS2AOP$$a3defe.search(SearchAction$$EnhancedByS2AOP$$a3defe.java)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.seasar.framework.util.MethodUtil.invoke(MethodUtil.java:96)
 at org.seasar.struts.action.ActionWrapper.execute(ActionWrapper.java:136)
 at org.seasar.struts.action.ActionWrapper.execute(ActionWrapper.java:86)
 at 
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 at 
org.seasar.struts.action.S2RequestProcessor.process(S2RequestProcessor.java:125)
 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.seasar.extension.filter.RequestDumpFilter.doFilter(RequestDumpFilter.java:127)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:75)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
 at 
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
 at 
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
 at 
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
 at org.seasar.struts.filter.RoutingFilter.forward(RoutingFilter.java:204)
 at org.seasar.struts.filter.RoutingFilter.doFilter(RoutingFilter.java:75)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:63)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.seasar.extension.filter.EncodingFilter.doFilter(EncodingFilter.java:69)
 at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
 at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Unknown Source)

以上 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tutorial.properties
Type: application/octet-stream
Size: 419 bytes
Desc: 無し
URL: <http://ml.seasar.org/archives/seasar-user/attachments/20081204/3ae118f5/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tutorial.script
Type: application/octet-stream
Size: 2614 bytes
Desc: 無し
URL: <http://ml.seasar.org/archives/seasar-user/attachments/20081204/3ae118f5/attachment-0003.obj>


Seasar-user メーリングリストの案内