★環境
/WebContent/WEB-INF/lib/s2-dao-1.0.39.jar
/WebContent/WEB-INF/lib/s2-dao-1.0.39-sources.jar
/WebContent/WEB-INF/lib/s2-extension-2.3.15.jar
/WebContent/WEB-INF/lib/s2-extension-2.3.15-sources.jar
/WebContent/WEB-INF/lib/s2-framework-2.3.15.jar
/WebContent/WEB-INF/lib/s2-framework-2.3.15-sources.jar
★追加テーブル
■テーブル名
new_table_list
■カラム
id:integer
item:varchar
■テーブル
------------------------------ id item ------------------------------ 1 orange 2 apple ------------------------------
★app.dicon [追記]
XML:
-
<component name="NewTableListDAO" class="jp.co.ezic.system.dao.NewTableListDAO">
-
<aspect>dao_system.interceptor</aspect>
-
</component>
-
<component name="NewTableListBO" class="jp.co.ezic.system.bo.NewTableListBO">
-
<property name="newTableListDao">NewTableListDAO</property>
-
</component>
★NewTableListBO.java [新規]
JAVA:
-
package jp.co.ezic.system.bo;
-
-
//import java.util.Date;
-
//import java.util.List;
-
-
import jp.co.ezic.system.dao.NewTableListDAO;
-
-
public class NewTableListBO {
-
-
private NewTableListDAO newTableListDAO;
-
-
public NewTableListBO() {
-
super();
-
S2Container container = SingletonS2ContainerFactory.getContainer();
-
this.setNewTableListDao((NewTableListDAO)container.getComponent(NewTableListDAO.class));
-
}
-
-
public NewTableListDAO getNewTableListDao() {
-
return newTableListDAO;
-
}
-
-
public void setNewTableListDao(NewTableListDAO newTableListDAO) {
-
this.newTableListDAO = newTableListDAO;
-
}
-
-
}
★ NewTableListDAO.java [新規]
JAVA:
-
package jp.co.ezic.system.dao;
-
-
//import java.util.ArrayList;
-
//import java.util.List;
-
-
import jp.co.ezic.system.entity.NewTableListBean;
-
-
public interface NewTableListDAO {
-
-
public Class BEAN=NewTableListBean.class;
-
-
-
public NewTableListBean getRecordById(int Id);
-
-
}
★ NewTableListBean.java [新規]
JAVA:
-
package jp.co.ezic.system.entity;
-
-
//import java.util.Date;
-
-
public class NewTableListBean {
-
-
//----------------
-
// 変数設定
-
//----------------
-
private int id;
-
private String item;
-
-
//----------------
-
// getter/setter
-
//----------------
-
public int getId() {
-
return id;
-
}
-
public void setId(int id) {
-
this.id = id;
-
}
-
-
return item;
-
}
-
this.item = item;
-
}
-
}
★ 実装先.java [追記]
JAVA:
-
import jp.co.ezic.system.dao.NewTableListDAO;
-
import jp.co.ezic.system.entity.NewTableListBean;
-
-
public class 実装先 {
-
//BO
-
private NewTableListBO newTableListBO;
-
-
public 実装先() {
-
super();
-
S2Container container = SingletonS2ContainerFactory.getContainer();
-
this.setNewTableListBO((NewTableListBO)container.getComponent(NewTableListBO.class));
-
}
-
-
// getter/setter
-
public NewTableListBO getNewTableListBO() {
-
return newTableListBO;
-
}
-
public void setNewTableListBO(NewTableListBO newTableListBO) {
-
this.newTableListBO = newTableListBO;
-
}
-
-
// 「public.new_table_list」からリスト取得
-
NewTableListBO ntlbo = this.getNewTableListBO();
-
NewTableListDAO ntldao = ntlbo.getNewTableListDao();
-
int whereId = 1; // 抽出条件
-
NewTableListBean ntlbean = ntldao.getRecordById(whereId);
-
String itemValue = "";
-
-
// レコード取得
-
if(ntlbean != null){
-
if(ntlbean.getItem() != null){
-
// 抽出条件がid=1なので、itemValueは「orange」になる
-
itemValue = ntlbean.getItem();
-
}
-
}
-
}