[Seasar-user:11707] [S2JDBC] timestamp型→Calendar型としての取得方法
[E-MAIL ADDRESS DELETED]
[E-MAIL ADDRESS DELETED]
2007年 11月 19日 (月) 21:54:26 JST
関修康です。
S2JDBCの機能を検証していたところ、PostgresにてTimestamp型のデータを
抽出する際に例外が発生しています。
s2jdbc-tutorialでも以下の方法で同様に例外が発生するため
Timestampをカレンダーに変換する操作自体に問題があるのでしょうか?
何かエラーにならない方法が有りましたら宜しくお願い致します。
■【編集】/s2jdbc-tutorial/src/test/resources/data/test.script
create table history(kiroku timestamp)
・・(省略)・・
INSERT INTO history VALUES('2007-10-10')
・・(省略)・・
■【追加】/s2jdbc-tutorial/src/main/java/examples/entity/History.java
package examples.entity;
import java.util.Calendar;
import javax.persistence.Entity;
@Entity
public class History {
public Calendar kiroku;
}
■【追加】/s2jdbc-tutorial/src/test/java/examples/entity/GetCalendarTest.java
package examples.entity;
import java.util.List;
import org.seasar.extension.jdbc.JdbcManager;
import org.seasar.extension.unit.S2TestCase;
public class GetCalendarTest extends S2TestCase {
private JdbcManager jdbcManager;
protected void setUp() throws Exception {
include("app.dicon");
}
public void testGetResultList() throws Exception {
List<History> results =jdbcManager.from(History.class).getResultList();
for (History e : results) {
System.out.println(e.kiroku);
}
}
}
■エラー内容
org.seasar.framework.exception.SIllegalArgumentException: [ESSR0094]IllegalArgumentExceptionがクラス(examples.entity.History)のフィールド(kiroku)に(07/10/10 0:00)を設定するときに発生しました。対象クラスは(examples.entity.History)です。
at org.seasar.framework.util.FieldUtil.set(FieldUtil.java:164)
at org.seasar.extension.jdbc.mapper.PropertyMapperImpl.setFieldValue(PropertyMapperImpl.java:71)
at org.seasar.extension.jdbc.mapper.PropertyMapperImpl.map(PropertyMapperImpl.java:56)
at org.seasar.extension.jdbc.mapper.AbstractEntityMapper.createEntity(AbstractEntityMapper.java:134)
at org.seasar.extension.jdbc.mapper.AbstractEntityMapper.getEntity(AbstractEntityMapper.java:114)
at org.seasar.extension.jdbc.mapper.EntityMapperImpl.map(EntityMapperImpl.java:48)
at org.seasar.extension.jdbc.handler.AbstractBeanAutoResultSetHandler.createEntity(AbstractBeanAutoResultSetHandler.java:85)
at org.seasar.extension.jdbc.handler.BeanListAutoResultSetHandler.handle(BeanListAutoResultSetHandler.java:56)
at org.seasar.extension.jdbc.query.AbstractQuery.handleResultSet(AbstractQuery.java:387)
at org.seasar.extension.jdbc.query.AbstractSelect.getResultListInternal(AbstractSelect.java:162)
at org.seasar.extension.jdbc.query.AbstractSelect.getResultList(AbstractSelect.java:141)
at examples.entity.GetCalendarTest.testGetResultList(GetCalendarTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at org.seasar.framework.unit.S2FrameworkTestCase.doRunTest(S2FrameworkTestCase.java:519)
at org.seasar.extension.unit.S2TestCase.doRunTest(S2TestCase.java:103)
at org.seasar.framework.unit.S2FrameworkTestCase.runBare(S2FrameworkTestCase.java:308)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.IllegalArgumentException
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:656)
at org.seasar.framework.util.FieldUtil.set(FieldUtil.java:159)
... 31 more
Seasar-user メーリングリストの案内