bbossプリコンパイルバッチapiの使用説明


bbossプリコンパイルバッチ処理機能は、データの一括挿入、一括削除、一括更新操作を非常に容易に行うことができる.一括操作とは一度にデータベースに複数の記録操作を実行することであり,bboss一括処理操作はすべてプリコンパイル方式で実行され,実行効率は非常によい.bboss永続層フレームワークにおける一括処理動作のapiおよび使用例について詳しく説明する.本題に切り込む.
1.関連コンポーネント
com.frameworkset.sqlexecutor.SQLExecutor-すべてのapiは静的メソッドで、元のsql文を直接操作し、すべてのメソッドは操作のデータソースを指定することも、指定しないこともできます(poolman.xmlファイルの最初のデータソースで対応するsqlを実行します)
com.frameworkset.sqlexecutor.ConfigSQLExecutor--すべてのapiはインスタンスメソッドであり、1つのConfigSQLExecutorオブジェクトインスタンスはsqlプロファイルパスをパラメータとする構造関数としてインスタンス化する必要があります.インスタンスのすべての方法では、sql文を直接使用することはできません.sqlプロファイルのsql文に対応する1つの構成sqlの名前しか指定できません.コンフィグSQLExecutorでは、すべてのメソッドでアクションのデータソースを指定できますが、指定しないこともできます(poolman.xmlファイルの最初のデータソースで対応するsqlが実行されます).
2.一括挿入操作
api
SQLExecutor.insertBeans(sql,beans);
SQLExecutor.insertBeans(dbname,sql,beans);

ConfigSQLExecutor.insertBeans(sqlname,beans);
ConfigSQLExecutor.insertBeans(dbname,sqlname,beans);

使用例-SQLExecutorを例に
public void batchadd(List<TestBean> newdatas)
	{				
		//sql      TestBean      ,       get/set  ,                 sql  
		String sql = "insert into LISTBEAN(ID,FIELDNAME,FIELDLABLE,FIELDTYPE,SORTORDER," +
				"ISPRIMARYKEY,REQUIRED,FIELDLENGTH,ISVALIDATED) " +
				"values(#[id],#[fieldName],#[fieldLable],#[fieldType],#[sortorder]," +
				"#[isprimaryKey],#[required],#[fieldLength],#[isvalidated])";
        //SQLExecutor.insertBeans(sql,newdatas);//        
		SQLExecutor.insertBeans("testds",//   
		                        sql,//   sql  
		                        newdatas//          
		                        );
	}

3.一括更新操作
api
SQLExecutor.updateBeans(sql,beans);
SQLExecutor.updateBeans(dbname,sql,beans);

ConfigSQLExecutor.updateBeans(sqlname,beans);
ConfigSQLExecutor.updateBeans(dbname,sqlname,beans);

使用例-SQLExecutorを例に

public void batchadd(List<TestBean> updatedatas)
{
       sql ="update LISTBEAN set FIELDNAME=#[fieldName] where ID=#[id]"; 
                  //SQLExecutor.updateBeans(sql,updatedatas);

		SQLExecutor.updateBeans("testds",sql,updatedatas);
}

4.一括削除操作
api
SQLExecutor.deleteBeans(sql,beans);
SQLExecutor.deleteBeans(dbname,sql,beans);
ConfigSQLExecutor.deleteBeans(sqlname,beans);
ConfigSQLExecutor.deleteBeans(dsname,sqlname,beans);

使用例-SQLExecutorを例に
public void batchadd(List<TestBean> updatedatas)
{
       sql ="delete  from LISTBEAN where ID=#[id]";   
       //SQLExecutor.deleteBeans(sql,beans);
       SQLExecutor.deleteBeans("mysql",sql,beans);
}

ここでbbossにおける3つの典型的なバッチ処理操作のapiおよび使用例について説明するが、poolmanについては説明する.xmlでデータ・ソースを構成するには、次の文書を参照してください.
http://yin-bp.iteye.com/blog/352599
コンフィグSQLExecutorコンポーネントのより詳細な使用例については、次の文書を参照してください.
http://yin-bp.iteye.com/blog/1112997
SQLExecutorコンポーネントのより詳細な使用例については、次の文書を参照してください.
http://yin-bp.iteye.com/blog/1035991
ここでは、単一のsql文のプリコンパイルバッチ処理を説明します.また、次の複数のsql文を参照して、プリコンパイルバッチ処理を同時に行う例も参照できます.
https://github.com/bbossgroups/bbossgroups-3.5/blob/master/bboss-persistent/test/com/frameworkset/common/TestPreparedBatch.java