[Seasar-user:20700] [S2JDBC] Postgresql: 主キーに GenerationType.IDENTITY を指定で insert 例外

[E-MAIL ADDRESS DELETED] [E-MAIL ADDRESS DELETED]
2011年 4月 1日 (金) 18:51:22 JST


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


@GeneratedValue(strategy = GenerationType.IDENTITY) だと insert で例外。

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

と定義されているエンティティで

    jdbcManager.insert( kokyaku ).execute();

を実行すると、

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)

の例外が発生。ID列が指定されています。

DDLは、

CREATE TABLE KOKYAKUS
(
 ID SERIAL NOT NULL,
...
-------------- next part --------------
HTMLの添付ファイルを保管しました...
URL: <http://ml.seasar.org/archives/seasar-user/attachments/20110401/2a9950e5/attachment.html>


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