[Seasar-user:20701] [S2JDBC] Postgresql9.0.3: 主キーが GenerationType.IDENTITY のテーブルで insert 例外

[E-MAIL ADDRESS DELETED] [E-MAIL ADDRESS DELETED]
2011年 4月 1日 (金) 19:06:17 JST


環境
DB: PostgreSQL 9.0.3
S2JDBC-Gen 2.4.43
s2-framework/tiger/extension-2.4.43

PostgreSQL で 

    /** idプロパティ */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(precision = 10, unique = true)
    public Integer id;

の主キーがあるエンティティで insert

    int kazu = jdbcManager.insert( kokyaku ).execute();

指定されないはずのID列が指定されて、例外が発生する。なぜ?

DDLは、

CREATE TABLE KOKYAKUS
(
 ID SERIAL NOT NULL,
...

ご教授をお願いします。

javax.servlet.ServletException: org.seasar.framework.exception.SQLRuntimeException: [ESSR0072]SQLで例外(SQL=[insert into KOKYAKUS (ID, CODE, LASTNAME1_KANJI, FIRSTNAME1_KANJI, LASTNAME1_KANA, FIRSTNAME1_KANA, TANTOU1, BUSHOYAKU1, postalcode1_1, postalcode1_2, PREFECTURE1, CITY1, TOWN1, BUIL1, tel1_1, tel1_2, tel1_3, fax1_1, fax1_2, fax1_3, TANTOU2, BUSHOYAKU2, postalcode2_1, postalcode2_2, PREFECTURE2, CITY2, TOWN2, BUIL2, tel2_1, tel2_2, tel2_3, fax2_1, fax2_2, fax2_3, OFFICENAME_KANJI, OFFICENAME_KANA, OFFICEPOST, postalcode0_1, postalcode0_2, PREFECTURE0, CITY0, TOWN0, BUIL0, tel0_1, tel0_2, tel0_3, fax0_1, fax0_2, fax0_3, mbtel_1, mbtel_2, mbtel_3, URL, MAIL, MBMAIL, BIRTHDAY) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], Message=[[ESSR0072]SQLで例外(SQL=[insert into KOKYAKUS (ID, CODE, LASTNAME1_KANJI, FIRSTNAME1_KANJI, LASTNAME1_KANA, FIRSTNAME1_KANA, TANTOU1, BUSHOYAKU1, postalcode1_1, postalcode1_2, PREFECTURE1, CITY1, TOWN1, BUIL1, tel1_1, tel1_2, tel1_3, fax1_1, fax1_2, fax1_3, TANTOU2, BUSHOYAKU2, postalcode2_1, postalcode2_2, PREFECTURE2, CITY2, TOWN2, BUIL2, tel2_1, tel2_2, tel2_3, fax2_1, fax2_2, fax2_3, OFFICENAME_KANJI, OFFICENAME_KANA, OFFICEPOST, postalcode0_1, postalcode0_2, PREFECTURE0, CITY0, TOWN0, BUIL0, tel0_1, tel0_2, tel0_3, fax0_1, fax0_2, fax0_3, mbtel_1, mbtel_2, mbtel_3, URL, MAIL, MBMAIL, BIRTHDAY) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], Message=[0], ErrorCode=23502, SQLState={3})が発生しました : [SQLで例外(Message=[ERROR: 列"id"内のNULL値はNOT NULL制約違反です], ErrorCode=0, SQLState=23502)が発生しました。], [ERROR: 列"id"内のNULL値はNOT NULL制約違反です], ErrorCode=0, SQLState=23502)が発生しました
 org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
 org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
 org.seasar.struts.action.S2RequestProcessor.process(S2RequestProcessor.java:132)
 org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
...

原因 

org.seasar.framework.exception.SQLRuntimeException: [ESSR0072]SQLで例外(SQL=[insert into KOKYAKUS (ID, CODE, LASTNAME1_KANJI, FIRSTNAME1_KANJI, LASTNAME1_KANA, FIRSTNAME1_KANA, TANTOU1, BUSHOYAKU1, postalcode1_1, postalcode1_2, PREFECTURE1, CITY1, TOWN1, BUIL1, tel1_1, tel1_2, tel1_3, fax1_1, fax1_2, fax1_3, TANTOU2, BUSHOYAKU2, postalcode2_1, postalcode2_2, PREFECTURE2, CITY2, TOWN2, BUIL2, tel2_1, tel2_2, tel2_3, fax2_1, fax2_2, fax2_3, OFFICENAME_KANJI, OFFICENAME_KANA, OFFICEPOST, postalcode0_1, postalcode0_2, PREFECTURE0, CITY0, TOWN0, BUIL0, tel0_1, tel0_2, tel0_3, fax0_1, fax0_2, fax0_3, mbtel_1, mbtel_2, mbtel_3, URL, MAIL, MBMAIL, BIRTHDAY) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], Message=[[ESSR0072]SQLで例外(SQL=[insert into KOKYAKUS (ID, CODE, LASTNAME1_KANJI, FIRSTNAME1_KANJI, LASTNAME1_KANA, FIRSTNAME1_KANA, TANTOU1, BUSHOYAKU1, postalcode1_1, postalcode1_2, PREFECTURE1, CITY1, TOWN1, BUIL1, tel1_1, tel1_2, tel1_3, fax1_1, fax1_2, fax1_3, TANTOU2, BUSHOYAKU2, postalcode2_1, postalcode2_2, PREFECTURE2, CITY2, TOWN2, BUIL2, tel2_1, tel2_2, tel2_3, fax2_1, fax2_2, fax2_3, OFFICENAME_KANJI, OFFICENAME_KANA, OFFICEPOST, postalcode0_1, postalcode0_2, PREFECTURE0, CITY0, TOWN0, BUIL0, tel0_1, tel0_2, tel0_3, fax0_1, fax0_2, fax0_3, mbtel_1, mbtel_2, mbtel_3, URL, MAIL, MBMAIL, BIRTHDAY) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], Message=[0], ErrorCode=23502, SQLState={3})が発生しました : [SQLで例外(Message=[ERROR: 列"id"内のNULL値はNOT NULL制約違反です], ErrorCode=0, SQLState=23502)が発生しました。], [ERROR: 列"id"内のNULL値はNOT NULL制約違反です], ErrorCode=0, SQLState=23502)が発生しました
 org.seasar.framework.util.PreparedStatementUtil.executeUpdate(PreparedStatementUtil.java:68)
 org.seasar.extension.jdbc.query.AbstractAutoUpdate.executeInternal(AbstractAutoUpdate.java:125)
 org.seasar.extension.jdbc.query.AbstractAutoUpdate.execute(AbstractAutoUpdate.java:90)
 jp.kaitorishahan.action.KokyakuAction.index(KokyakuAction.java:51)
...

原因 

org.seasar.framework.exception.SSQLException: [ESSR0072]SQLで例外(SQL=[insert into KOKYAKUS (ID, CODE, LASTNAME1_KANJI, FIRSTNAME1_KANJI, LASTNAME1_KANA, FIRSTNAME1_KANA, TANTOU1, BUSHOYAKU1, postalcode1_1, postalcode1_2, PREFECTURE1, CITY1, TOWN1, BUIL1, tel1_1, tel1_2, tel1_3, fax1_1, fax1_2, fax1_3, TANTOU2, BUSHOYAKU2, postalcode2_1, postalcode2_2, PREFECTURE2, CITY2, TOWN2, BUIL2, tel2_1, tel2_2, tel2_3, fax2_1, fax2_2, fax2_3, OFFICENAME_KANJI, OFFICENAME_KANA, OFFICEPOST, postalcode0_1, postalcode0_2, PREFECTURE0, CITY0, TOWN0, BUIL0, tel0_1, tel0_2, tel0_3, fax0_1, fax0_2, fax0_3, mbtel_1, mbtel_2, mbtel_3, URL, MAIL, MBMAIL, BIRTHDAY) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], Message=[0], ErrorCode=23502, SQLState={3})が発生しました
 org.seasar.extension.jdbc.impl.PreparedStatementWrapper.wrapException(PreparedStatementWrapper.java:72)
 org.seasar.extension.jdbc.impl.PreparedStatementWrapper.wrapException(PreparedStatementWrapper.java:67)
 org.seasar.extension.jdbc.impl.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:91)
 org.seasar.framework.util.PreparedStatementUtil.executeUpdate(PreparedStatementUtil.java:66)
 org.seasar.extension.jdbc.query.AbstractAutoUpdate.executeInternal(AbstractAutoUpdate.java:125)
 org.seasar.extension.jdbc.query.AbstractAutoUpdate.execute(AbstractAutoUpdate.java:90)
 jp.kaitorishahan.action.KokyakuAction.index(KokyakuAction.java:51)
...

原因 

org.postgresql.util.PSQLException: ERROR: 列"id"内のNULL値はNOT NULL制約違反です
 org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
 org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
 org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
 org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
 org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
 org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
 org.seasar.extension.jdbc.impl.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:89)
 org.seasar.framework.util.PreparedStatementUtil.executeUpdate(PreparedStatementUtil.java:66)
 org.seasar.extension.jdbc.query.AbstractAutoUpdate.executeInternal(AbstractAutoUpdate.java:125)
 org.seasar.extension.jdbc.query.AbstractAutoUpdate.execute(AbstractAutoUpdate.java:90)
 jp.kaitorishahan.action.KokyakuAction.index(KokyakuAction.java:51)
...


 
-------------- next part --------------
HTMLの添付ファイルを保管しました...
URL: <http://ml.seasar.org/archives/seasar-user/attachments/20110401/be70b66e/attachment.html>


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