テーブルを直したので・・・
次はBEANとかDAOを直さないとね。
BelongToEntity.java
public class BelongToEntity { public static final String TABLE = "BELONGTO"; private int belongToCode; private String belongToName = null; public int getBelongToCode() { return belongToCode; } public void setBelongToCode(int belongToCode) { this.belongToCode = belongToCode; } public String getBelongToName() { return belongToName; } public void setBelongToName(String belongToName) { this.belongToName = belongToName; } }
次にDAOのインターフェースをちょこっと修正
BelongToDao.java
public interface BelongToDao { public Class BEAN = BelongToEntity.class; public int insert(BelongToEntity belongToEntity); public BelongToEntity getBelongToEntity(int belongToCode); }
最後にテストプログラムを修正(←コレってTDDに反しているよな〜。本来なら真っ先にここを修正すべきなんだよな)
BelongToDaoTest.java
public class BelongToDaoTest extends TestCase { public final void testGetOne() { S2Container container = S2ContainerFactory .create("redrisefirm/seasar/s2dao/dao.dicon"); container.init(); //DAOの取得 BelongToDao belongToDao = (BelongToDao) container.getComponent(BelongToDao.class); //Entityの取得 BelongToEntity belongToEntity = belongToDao.getBelongToEntity(1); //答え合わせ assertEquals("値が違います", 1, belongToEntity.getBelongToCode()); assertEquals("値が違います", "地球連邦", belongToEntity.getBelongToName()); } public final void testGetTwo() { S2Container container = S2ContainerFactory .create("redrisefirm/seasar/s2dao/dao.dicon"); container.init(); //DAOの取得 BelongToDao belongToDao = (BelongToDao) container.getComponent(BelongToDao.class); //Entityの取得 BelongToEntity belongToEntity = belongToDao.getBelongToEntity(2); //答え合わせ assertEquals("値が違います", 2, belongToEntity.getBelongToCode()); assertEquals("値が違います", "ジオン公国", belongToEntity.getBelongToName()); } }
してテストを実行。
う〜ん、通らない。やっぱり2番目が取れない。
とすると原因は別のところか・・・