Package nablarch.common.dao
Class BasicDaoContext
java.lang.Object
nablarch.common.dao.BasicDaoContext
- All Implemented Interfaces:
- DaoContext
DaoContextのデフォルト実装クラス。- 
Method SummaryModifier and TypeMethodDescription<T> voidbatchDelete(List<T> entities) エンティティオブジェクトを元に一括削除処理を行う。<T> voidbatchInsert(List<T> entities) エンティティオブジェクトの情報を一括で登録する。<T> voidbatchUpdate(List<T> entities) エンティティオブジェクトの情報を元に一括更新を行う。<T> longcountBySqlFile(Class<T> entityClass, String sqlId, Object params) SQL_IDをもとに結果件数を取得する。defer()検索結果の取得を遅延させる。<T> intdelete(T entity) エンティティオブジェクトを元に削除処理を行う。protected nablarch.common.dao.SqlResourceHolderexecuteQuery(String normalizedSqlId, Object params, SelectOption selectOption) 検索クエリを実行する。<T> EntityList<T>全件の検索を行う。<T> EntityList<T>findAllBySqlFile(Class<T> entityClass, String sqlId) SQL_IDをもとに検索を行う。<T> EntityList<T>findAllBySqlFile(Class<T> entityClass, String sqlId, Object params) SQL_IDをもとにバインド変数を展開して検索処理を行う。protected <T> EntityList<T>findAllBySqlFileWithoutPaginate(Class<T> entityClass, String sqlId, Object params) ページングなしの場合の検索を実行する。protected <T> EntityList<T>findAllBySqlFIleWithPaginate(Class<T> entityClass, String sqlId, Object params) ページネーションつきの検索を実行する。<T> Tプライマリーキーによる検索を行う。<T> TfindByIdOrNull(Class<T> entityClass, Object... id) プライマリーキーによる検索を行う。<T> TfindBySqlFile(Class<T> entityClass, String sqlId, Object params) SQL_IDをもとに1件検索を行う。<T> TfindBySqlFileOrNull(Class<T> entityClass, String sqlId, Object params) SQL_IDをもとに1件検索を行う。<T> voidinsert(T entity) エンティティオブジェクトを元に登録処理を行う。protected <T> StringnormalizeSqlId(String sqlId, Class<T> entityClass) SQL_IDにファイル名がついてない場合は、Entityクラスの完全修飾名を付加する。page(long page) ページングの何ページ目を検索するかを指定する。per(long per) ページングの1ページにつき何件表示するかを指定する。protected voidsetDbConnection(AppDbConnection dbConnection) 使用するデータベースコネクションを設定する。protected voidsetIdGenerator(jakarta.persistence.GenerationType type, IdGenerator generator) IDジェネレータを設定する。<T> StringtableName(T entity) エンティティクラス名からテーブル名へ変換する。<T> intupdate(T entity) エンティティオブジェクトを元に更新処理を行う。
- 
Method Details- 
findByIdプライマリーキーによる検索を行う。 この実装では、プライマリーキーのメタデータをDatabaseMetaDataから取得する。- Specified by:
- findByIdin interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entityClass- エンティティクラス
- id- プライマリーキー (複合キーの場合は定義順)
- Returns:
- エンティティオブジェクト
- Throws:
- IllegalArgumentException- (主キーのカラム数と指定した条件数が一致しない場合)
- NoDataException- (検索条件に該当するレコードが存在しない場合)
 
- 
findByIdOrNullプライマリーキーによる検索を行う。 この実装では、プライマリーキーのメタデータをDatabaseMetaDataから取得する。- Specified by:
- findByIdOrNullin interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entityClass- エンティティクラス
- id- プライマリーキー (複合キーの場合は定義順)
- Returns:
- エンティティオブジェクト。0件の場合はnull。
- Throws:
- IllegalArgumentException- (主キーのカラム数と指定した条件数が一致しない場合)
 
- 
findAllDescription copied from interface:DaoContext全件の検索を行う。- Specified by:
- findAllin interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entityClass- エンティティクラス
- Returns:
- 検索結果リスト。0件の場合は空リスト。
 
- 
findAllBySqlFileDescription copied from interface:DaoContextSQL_IDをもとにバインド変数を展開して検索処理を行う。- Specified by:
- findAllBySqlFilein interface- DaoContext
- Type Parameters:
- T- 検索結果をマッピングするBeanクラスの型
- Parameters:
- entityClass- 検索結果をマッピングするBeanクラス
- sqlId- SQL_ID
- params- バインド変数
- Returns:
- 検索結果リスト。0件の場合は空リスト。
 
- 
findAllBySqlFileDescription copied from interface:DaoContextSQL_IDをもとに検索を行う。- Specified by:
- findAllBySqlFilein interface- DaoContext
- Type Parameters:
- T- 検索結果をマッピングするBeanクラスの型
- Parameters:
- entityClass- 検索結果をマッピングするBeanクラス
- sqlId- SQL_ID
- Returns:
- 検索結果リスト。0件の場合は空リスト。
 
- 
executeQueryprotected nablarch.common.dao.SqlResourceHolder executeQuery(String normalizedSqlId, Object params, SelectOption selectOption) 検索クエリを実行する。- Parameters:
- normalizedSqlId- SQL ID
- params- バインド変数
- selectOption- 検索オプション
- Returns:
- 検索結果
 
- 
findAllBySqlFileWithoutPaginateprotected <T> EntityList<T> findAllBySqlFileWithoutPaginate(Class<T> entityClass, String sqlId, Object params) ページングなしの場合の検索を実行する。- Type Parameters:
- T- エンティティクラス
- Parameters:
- entityClass- エンティティクラス
- sqlId- SQL ID
- params- バインド変数
- Returns:
- エンティティクラスのリスト
 
- 
findAllBySqlFIleWithPaginateprotected <T> EntityList<T> findAllBySqlFIleWithPaginate(Class<T> entityClass, String sqlId, Object params) ページネーションつきの検索を実行する。 遅延ロード(deferがtrueの場合)、IllegalArgumentExceptionを送出する。- Type Parameters:
- T- エンティティクラス
- Parameters:
- entityClass- エンティティクラス
- sqlId- SQL ID
- params- バインド変数
- Returns:
- エンティティリストを返します。
 
- 
findBySqlFileSQL_IDをもとに1件検索を行う。- Specified by:
- findBySqlFilein interface- DaoContext
- Type Parameters:
- T- 検索結果をマッピングするBeanクラスの型
- Parameters:
- entityClass- 検索結果をマッピングするBeanクラス
- sqlId- SQL_ID
- params- バインド変数
- Returns:
- エンティティオブジェクト
- Throws:
- NoDataException- (検索条件に該当するレコードが存在しない場合)
 
- 
findBySqlFileOrNullSQL_IDをもとに1件検索を行う。- Specified by:
- findBySqlFileOrNullin interface- DaoContext
- Type Parameters:
- T- 検索結果をマッピングするBeanクラスの型
- Parameters:
- entityClass- 検索結果をマッピングするBeanクラス
- sqlId- SQL_ID
- params- バインド変数
- Returns:
- エンティティオブジェクト。0件の場合はnull。
 
- 
countBySqlFileDescription copied from interface:DaoContextSQL_IDをもとに結果件数を取得する。- Specified by:
- countBySqlFilein interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entityClass- エンティティクラス
- sqlId- SQL_ID
- params- バインド変数
- Returns:
- 件数
 
- 
updatepublic <T> int update(T entity) throws jakarta.persistence.OptimisticLockException Description copied from interface:DaoContextエンティティオブジェクトを元に更新処理を行う。 エンティティの主キーが更新条件となる。- Specified by:
- updatein interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entity- エンティティオブジェクト
- Returns:
- 更新件数
- Throws:
- jakarta.persistence.OptimisticLockException- バージョン不一致で更新対象が存在しない場合
 
- 
batchUpdateDescription copied from interface:DaoContextエンティティオブジェクトの情報を元に一括更新を行う。DaoContext.update(Object)とは異なり、一括更新処理ではバージョン不一致チェックは行わない。 例えば、バージョン番号が変更になっていた場合はそのレコードのみ更新されずに処理は正常に終了する。 バージョン番号のチェックを必要とする場合には、DaoContext.update(Object)を使用すること。- Specified by:
- batchUpdatein interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entities- 更新対象のエンティティリスト
 
- 
insertpublic <T> void insert(T entity) Description copied from interface:DaoContextエンティティオブジェクトを元に登録処理を行う。- Specified by:
- insertin interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entity- エンティティオブジェクト
 
- 
batchInsertDescription copied from interface:DaoContextエンティティオブジェクトの情報を一括で登録する。- Specified by:
- batchInsertin interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entities- エンティティリスト
 
- 
deletepublic <T> int delete(T entity) Description copied from interface:DaoContextエンティティオブジェクトを元に削除処理を行う。 エンティティの主キーが削除条件となる。- Specified by:
- deletein interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entity- エンティティオブジェクト
- Returns:
- 削除件数
 
- 
batchDeleteDescription copied from interface:DaoContextエンティティオブジェクトを元に一括削除処理を行う。 エンティティの主キーが削除条件となる。- Specified by:
- batchDeletein interface- DaoContext
- Type Parameters:
- T- エンティティクラスの型
- Parameters:
- entities- エンティティリスト
 
- 
tableNameエンティティクラス名からテーブル名へ変換する。- Type Parameters:
- T- エンティティクラス
- Parameters:
- entity- エンティティ
- Returns:
- テーブル名
 
- 
pageDescription copied from interface:DaoContextページングの何ページ目を検索するかを指定する。- Specified by:
- pagein interface- DaoContext
- Parameters:
- page- ページ番号(1-origin)
- Returns:
- DaoContextがそのまま返る。
 
- 
perDescription copied from interface:DaoContextページングの1ページにつき何件表示するかを指定する。- Specified by:
- perin interface- DaoContext
- Parameters:
- per- ページ内表示件数
- Returns:
- DaoContextがそのまま返る。
 
- 
deferDescription copied from interface:DaoContext検索結果の取得を遅延させる。- Specified by:
- deferin interface- DaoContext
- Returns:
- DaoContextがそのまま返る。
 
- 
normalizeSqlIdSQL_IDにファイル名がついてない場合は、Entityクラスの完全修飾名を付加する。- Type Parameters:
- T- エンティティ型
- Parameters:
- sqlId- SQL ID
- entityClass- エンティティクラス
- Returns:
- 正規化したSQL ID
 
- 
setIdGeneratorIDジェネレータを設定する。- Parameters:
- type- IDジェネレータのタイプ
- generator- IDジェネレータ
 
- 
setDbConnection使用するデータベースコネクションを設定する。- Parameters:
- dbConnection- データベースコネクション
 
 
-