S2DAOに取り組んでみる
JDBC、Hibernate、iBatisときたので、S2DAOにも取り組んでみる。なんかSQLファイルは外だしで、単体で実行出来るらしい。好印象。
でもって、とりあえず現時点で最新のS2 2.2.10と、S2DAO1.0.28をセットアップして動かそうとすると、こんなエラーが出た。
Exception in thread "main" java.lang.NullPointerException at org.seasar.dao.interceptors.S2DaoInterceptor.invoke(S2DaoInterceptor.java:34) at s2.CustomerDao$$EnhancedByS2AOP$$15ee671$$MethodInvocation$$getAllCustomers0.proceed(MethodInvocationClassGenerator.java) at s2.CustomerDao$$EnhancedByS2AOP$$15ee671.getAllCustomers(CustomerDao$$EnhancedByS2AOP$$15ee671.java) at s2.Test.main(Test.java:19)
なんか、s2.CustomerDao$$EnhancedByS2AOP$$15ee671.getAllCustomersの辺りが、AOPっていう感じなのかねぇとか思いつつ、全く動かないのでとりあえずあきらめました。
http://blog.ozacc.com/archives/001027.html
な情報もあるので、j2ee.diconファイルとか設定周りの問題なのかも。でも、NullPointerExceptionじゃ分からんよなー。あんまりやさしくないので悪印象。。
→http://www.seasar.org/s2dao.htmlのdiconファイルの書き方に従ってみたら動きました。
<component class="org.seasar.dao.impl.DaoMetaDataFactoryImpl"/>
ってのが、あるかないかだけの差のような気がするのですが、大きな違いなんですかね。
残念ながら、アーカイブに入っているオフラインのドキュメントは微妙に古いようです。