s2daoのバージョンアップ(1.0.34 → 1.0.35)検証を行って
いたところ、
下記の例外が発生しました。
org.seasar.framework.exception.SRuntimeException:
[EDAO0014]not nullであるカラムがありません
at org.seasar.dao.impl.InsertAutoDynamicCommand.createInsertPropertyTypes(InsertAutoDynamicCommand.java:119)
at org.seasar.dao.impl.InsertAutoDynamicCommand.execute(InsertAutoDynamicCommand.java:52)
at org.seasar.dao.interceptors.S2DaoInterceptor.invoke(S2DaoInterceptor.java:53)
状況としてはPKのみ存在するテーブルへInsertを行った時に発
生しました。
とりあえずEclipseにてステップ実行を行い確認したところ
org.seasar.dao.impl.InsertAutoDynamicCommand#createInsertPropertyTypes
内の
判定で以下の様な違いがあるため、notNullColumnsと判定され
ず発生しているようです。
・1.0.35の場合
if (pt.isPrimaryKey()) { if (!identifierGenerator.isSelfGenerate()) { continue; } } else if (pt.getPropertyDesc().getValue(bean) == null) { ← ※※ここ※※ final String propertyName = pt.getPropertyName(); if (!propertyName.equalsIgnoreCase(timestampPropertyName) && !propertyName.equalsIgnoreCase(versionNoPropertyName)) { continue; } } else { notNullColumns++; }
・1.0.34の場合
if (pt.isPrimaryKey() && !identifierGenerator.isSelfGenerate()) { continue; } if (pt.getPropertyDesc().getValue(bean) == null) { ← ※※ここ※※ final String propertyName = pt.getPropertyName(); if (!propertyName.equalsIgnoreCase(timestampPropertyName) && !propertyName.equals(versionNoPropertyName)) { continue; } } else { notNullColumns++; }
以下がソースの抜粋になります。
CREATE TABLE humo (
hoge1 INTEGER NOT NULL
,hoge2 INTEGER NOT NULL
,PRIMARY KEY(hoge1, hoge2)
);
@Bean(table = "humo")
public class Humo {
private Integer hoge1_;
private Integer hoge2_;
@Column("hoge1")
public void setHoge1(Integer hoge1) { hoge1_ = hoge1;
}
public Integer getHoge1() { return hoge1_; }
@Column("hoge2")
public void setHoge2(Integer hoge2) { hoge2_ = hoge2;
}
public Integer getHoge2() { return hoge2_; }
}
@S2Dao(bean = Humo.class)
public interface HumoDao {
int insert(Humo humo);
}
public class HumoDaoTest extends S2DaoTestCase {
private HumoDao humoDao_;
public void testInsertTx() throws Exception {
Humo humo = new Humo();
humo.setHoge1(10);
humo.setHoge2(11);
humoDao_.insert(humo);
}
}