org.codelibs.fess.crawler.db.bsbhv.BsAccessResultDataBhv Maven / Gradle / Ivy
/*
* Copyright 2012-2016 CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.codelibs.fess.crawler.db.bsbhv;
import java.util.List;
import org.dbflute.*;
import org.dbflute.bhv.*;
import org.dbflute.bhv.readable.*;
import org.dbflute.bhv.writable.*;
import org.dbflute.bhv.referrer.*;
import org.dbflute.cbean.*;
import org.dbflute.cbean.chelper.HpSLSFunction;
import org.dbflute.cbean.result.*;
import org.dbflute.exception.*;
import org.dbflute.optional.OptionalEntity;
import org.dbflute.outsidesql.executor.*;
import org.codelibs.fess.crawler.db.exbhv.*;
import org.codelibs.fess.crawler.db.bsbhv.loader.*;
import org.codelibs.fess.crawler.db.exentity.*;
import org.codelibs.fess.crawler.db.bsentity.dbmeta.*;
import org.codelibs.fess.crawler.db.cbean.*;
/**
* The behavior of ACCESS_RESULT_DATA as TABLE.
*
* [primary key]
* ID
*
* [column]
* ID, TRANSFORMER_NAME, DATA, ENCODING
*
* [sequence]
*
*
* [identity]
*
*
* [version-no]
*
*
* [foreign table]
* ACCESS_RESULT
*
* [referrer table]
*
*
* [foreign property]
* accessResult
*
* [referrer property]
*
*
* @author DBFlute(AutoGenerator)
*/
public abstract class BsAccessResultDataBhv extends AbstractBehaviorWritable {
// ===================================================================================
// Definition
// ==========
/*df:beginQueryPath*/
/** Delete All AccessResultData */
public static final String PATH_deleteAllAccessResultData = "deleteAllAccessResultData";
/*df:endQueryPath*/
// ===================================================================================
// DB Meta
// =======
/** {@inheritDoc} */
public AccessResultDataDbm asDBMeta() { return AccessResultDataDbm.getInstance(); }
/** {@inheritDoc} */
public String asTableDbName() { return "ACCESS_RESULT_DATA"; }
// ===================================================================================
// New Instance
// ============
/** {@inheritDoc} */
public AccessResultDataCB newConditionBean() { return new AccessResultDataCB(); }
// ===================================================================================
// Count Select
// ============
/**
* Select the count of uniquely-selected records by the condition-bean. {IgnorePagingCondition, IgnoreSpecifyColumn}
* SpecifyColumn is ignored but you can use it only to remove text type column for union's distinct.
*
* int count = accessResultDataBhv.selectCount(cb -> {
* cb.query().set...
* });
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The count for the condition. (NotMinus)
*/
public int selectCount(CBCall cbLambda) {
return facadeSelectCount(createCB(cbLambda));
}
// ===================================================================================
// Entity Select
// =============
/**
* Select the entity by the condition-bean.
* It returns not-null optional entity, so you should ...
* If the data is always present as your business rule, alwaysPresent().
* If it might be no data, isPresent() and orElse(), ...
*
* // if the data always exists as your business rule
* accessResultDataBhv.selectEntity(cb -> {
* cb.query().set...
* }).alwaysPresent(accessResultData -> {
* // called if present, or exception
* ... = accessResultData.get...
* });
*
* // if it might be no data, ...
* accessResultDataBhv.selectEntity(cb -> {
* cb.query().set...
* }).ifPresent(accessResultData -> {
* // called if present
* ... = accessResultData.get...
* }).orElse(() -> {
* // called if not present
* });
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The optional entity selected by the condition. (NotNull: if no data, empty entity)
* @throws EntityAlreadyDeletedException When get(), required() of return value is called and the value is null, which means entity has already been deleted (not found).
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws SelectEntityConditionNotFoundException When the condition for selecting an entity is not found.
*/
public OptionalEntity selectEntity(CBCall cbLambda) {
return facadeSelectEntity(createCB(cbLambda));
}
protected OptionalEntity facadeSelectEntity(AccessResultDataCB cb) {
return doSelectOptionalEntity(cb, typeOfSelectedEntity());
}
protected OptionalEntity doSelectOptionalEntity(AccessResultDataCB cb, Class extends ENTITY> tp) {
return createOptionalEntity(doSelectEntity(cb, tp), cb);
}
protected Entity doReadEntity(ConditionBean cb) { return facadeSelectEntity(downcast(cb)).orElse(null); }
/**
* Select the entity by the condition-bean with deleted check.
* If the data is always present as your business rule, this method is good.
*
* AccessResultData accessResultData = accessResultDataBhv.selectEntityWithDeletedCheck(cb -> cb.acceptPK(1));
* ... = accessResultData.get...(); // the entity always be not null
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The entity selected by the condition. (NotNull: if no data, throws exception)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws SelectEntityConditionNotFoundException When the condition for selecting an entity is not found.
*/
public AccessResultData selectEntityWithDeletedCheck(CBCall cbLambda) {
return facadeSelectEntityWithDeletedCheck(createCB(cbLambda));
}
/**
* Select the entity by the primary-key value.
* @param id : PK, NotNull, BIGINT(19), FK to ACCESS_RESULT. (NotNull)
* @return The optional entity selected by the PK. (NotNull: if no data, empty entity)
* @throws EntityAlreadyDeletedException When get(), required() of return value is called and the value is null, which means entity has already been deleted (not found).
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws SelectEntityConditionNotFoundException When the condition for selecting an entity is not found.
*/
public OptionalEntity selectByPK(Long id) {
return facadeSelectByPK(id);
}
protected OptionalEntity facadeSelectByPK(Long id) {
return doSelectOptionalByPK(id, typeOfSelectedEntity());
}
protected ENTITY doSelectByPK(Long id, Class extends ENTITY> tp) {
return doSelectEntity(xprepareCBAsPK(id), tp);
}
protected OptionalEntity doSelectOptionalByPK(Long id, Class extends ENTITY> tp) {
return createOptionalEntity(doSelectByPK(id, tp), id);
}
protected AccessResultDataCB xprepareCBAsPK(Long id) {
assertObjectNotNull("id", id);
return newConditionBean().acceptPK(id);
}
// ===================================================================================
// List Select
// ===========
/**
* Select the list as result bean.
*
* ListResultBean<AccessResultData> accessResultDataList = accessResultDataBhv.selectList(cb -> {
* cb.query().set...;
* cb.query().addOrderBy...;
* });
* for (AccessResultData accessResultData : accessResultDataList) {
* ... = accessResultData.get...;
* }
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The result bean of selected list. (NotNull: if no data, returns empty list)
* @throws DangerousResultSizeException When the result size is over the specified safety size.
*/
public ListResultBean selectList(CBCall cbLambda) {
return facadeSelectList(createCB(cbLambda));
}
@Override
protected boolean isEntityDerivedMappable() { return true; }
// ===================================================================================
// Page Select
// ===========
/**
* Select the page as result bean.
* (both count-select and paging-select are executed)
*
* PagingResultBean<AccessResultData> page = accessResultDataBhv.selectPage(cb -> {
* cb.query().set...
* cb.query().addOrderBy...
* cb.paging(20, 3); // 20 records per a page and current page number is 3
* });
* int allRecordCount = page.getAllRecordCount();
* int allPageCount = page.getAllPageCount();
* boolean isExistPrePage = page.isExistPrePage();
* boolean isExistNextPage = page.isExistNextPage();
* ...
* for (AccessResultData accessResultData : page) {
* ... = accessResultData.get...;
* }
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The result bean of selected page. (NotNull: if no data, returns bean as empty list)
* @throws DangerousResultSizeException When the result size is over the specified safety size.
*/
public PagingResultBean selectPage(CBCall cbLambda) {
return facadeSelectPage(createCB(cbLambda));
}
// ===================================================================================
// Cursor Select
// =============
/**
* Select the cursor by the condition-bean.
*
* accessResultDataBhv.selectCursor(cb -> {
* cb.query().set...
* }, member -> {
* ... = member.getMemberName();
* });
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @param entityLambda The handler of entity row of AccessResultData. (NotNull)
*/
public void selectCursor(CBCall cbLambda, EntityRowHandler entityLambda) {
facadeSelectCursor(createCB(cbLambda), entityLambda);
}
// ===================================================================================
// Scalar Select
// =============
/**
* Select the scalar value derived by a function from uniquely-selected records.
* You should call a function method after this method called like as follows:
*
* accessResultDataBhv.selectScalar(Date.class).max(cb -> {
* cb.specify().column...; // required for the function
* cb.query().set...
* });
*
* @param The type of result.
* @param resultType The type of result. (NotNull)
* @return The scalar function object to specify function for scalar value. (NotNull)
*/
public HpSLSFunction selectScalar(Class resultType) {
return facadeScalarSelect(resultType);
}
// ===================================================================================
// Sequence
// ========
@Override
protected Number doReadNextVal() {
String msg = "This table is NOT related to sequence: " + asTableDbName();
throw new UnsupportedOperationException(msg);
}
// ===================================================================================
// Load Referrer
// =============
/**
* Load referrer for the list by the referrer loader.
*
* List<Member> memberList = memberBhv.selectList(cb -> {
* cb.query().set...
* });
* memberBhv.load(memberList, memberLoader -> {
* memberLoader.loadPurchase(purchaseCB -> {
* purchaseCB.setupSelect...
* purchaseCB.query().set...
* purchaseCB.query().addOrderBy...
* }); // you can also load nested referrer from here
* //}).withNestedReferrer(purchaseLoader -> {
* // purchaseLoader.loadPurchasePayment(...);
* //});
*
* // you can also pull out foreign table and load its referrer
* // (setupSelect of the foreign table should be called)
* //memberLoader.pulloutMemberStatus().loadMemberLogin(...)
* });
* for (Member member : memberList) {
* List<Purchase> purchaseList = member.getPurchaseList();
* for (Purchase purchase : purchaseList) {
* ...
* }
* }
*
* About internal policy, the value of primary key (and others too) is treated as case-insensitive.
* The condition-bean, which the set-upper provides, has order by FK before callback.
* @param accessResultDataList The entity list of accessResultData. (NotNull)
* @param loaderLambda The callback to handle the referrer loader for actually loading referrer. (NotNull)
*/
public void load(List accessResultDataList, ReferrerLoaderHandler loaderLambda) {
xassLRArg(accessResultDataList, loaderLambda);
loaderLambda.handle(new LoaderOfAccessResultData().ready(accessResultDataList, _behaviorSelector));
}
/**
* Load referrer for the entity by the referrer loader.
*
* Member member = memberBhv.selectEntityWithDeletedCheck(cb -> cb.acceptPK(1));
* memberBhv.load(member, memberLoader -> {
* memberLoader.loadPurchase(purchaseCB -> {
* purchaseCB.setupSelect...
* purchaseCB.query().set...
* purchaseCB.query().addOrderBy...
* }); // you can also load nested referrer from here
* //}).withNestedReferrer(purchaseLoader -> {
* // purchaseLoader.loadPurchasePayment(...);
* //});
*
* // you can also pull out foreign table and load its referrer
* // (setupSelect of the foreign table should be called)
* //memberLoader.pulloutMemberStatus().loadMemberLogin(...)
* });
* List<Purchase> purchaseList = member.getPurchaseList();
* for (Purchase purchase : purchaseList) {
* ...
* }
*
* About internal policy, the value of primary key (and others too) is treated as case-insensitive.
* The condition-bean, which the set-upper provides, has order by FK before callback.
* @param accessResultData The entity of accessResultData. (NotNull)
* @param loaderLambda The callback to handle the referrer loader for actually loading referrer. (NotNull)
*/
public void load(AccessResultData accessResultData, ReferrerLoaderHandler loaderLambda) {
xassLRArg(accessResultData, loaderLambda);
loaderLambda.handle(new LoaderOfAccessResultData().ready(xnewLRAryLs(accessResultData), _behaviorSelector));
}
// ===================================================================================
// Pull out Relation
// =================
/**
* Pull out the list of foreign table 'AccessResult'.
* @param accessResultDataList The list of accessResultData. (NotNull, EmptyAllowed)
* @return The list of foreign table. (NotNull, EmptyAllowed, NotNullElement)
*/
public List pulloutAccessResult(List accessResultDataList)
{ return helpPulloutInternally(accessResultDataList, "accessResult"); }
// ===================================================================================
// Extract Column
// ==============
/**
* Extract the value list of (single) primary key id.
* @param accessResultDataList The list of accessResultData. (NotNull, EmptyAllowed)
* @return The list of the column value. (NotNull, EmptyAllowed, NotNullElement)
*/
public List extractIdList(List accessResultDataList)
{ return helpExtractListInternally(accessResultDataList, "id"); }
// ===================================================================================
// Entity Update
// =============
/**
* Insert the entity modified-only. (DefaultConstraintsEnabled)
*
* AccessResultData accessResultData = new AccessResultData();
* // if auto-increment, you don't need to set the PK value
* accessResultData.setFoo...(value);
* accessResultData.setBar...(value);
* // you don't need to set values of common columns
* //accessResultData.setRegisterUser(value);
* //accessResultData.set...;
* accessResultDataBhv.insert(accessResultData);
* ... = accessResultData.getPK...(); // if auto-increment, you can get the value after
*
* While, when the entity is created by select, all columns are registered.
* @param accessResultData The entity of insert. (NotNull, PrimaryKeyNullAllowed: when auto-increment)
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void insert(AccessResultData accessResultData) {
doInsert(accessResultData, null);
}
/**
* Update the entity modified-only. (ZeroUpdateException, NonExclusiveControl)
* By PK as default, and also you can update by unique keys using entity's uniqueOf().
*
* AccessResultData accessResultData = new AccessResultData();
* accessResultData.setPK...(value); // required
* accessResultData.setFoo...(value); // you should set only modified columns
* // you don't need to set values of common columns
* //accessResultData.setRegisterUser(value);
* //accessResultData.set...;
* // if exclusive control, the value of concurrency column is required
* accessResultData.setVersionNo(value);
* accessResultDataBhv.update(accessResultData);
*
* @param accessResultData The entity of update. (NotNull, PrimaryKeyNotNull)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void update(AccessResultData accessResultData) {
doUpdate(accessResultData, null);
}
/**
* Insert or update the entity modified-only. (DefaultConstraintsEnabled, NonExclusiveControl)
* if (the entity has no PK) { insert() } else { update(), but no data, insert() }
* Also you can update by unique keys using entity's uniqueOf().
* @param accessResultData The entity of insert or update. (NotNull, ...depends on insert or update)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void insertOrUpdate(AccessResultData accessResultData) {
doInsertOrUpdate(accessResultData, null, null);
}
/**
* Delete the entity. (ZeroUpdateException, NonExclusiveControl)
* By PK as default, and also you can delete by unique keys using entity's uniqueOf().
*
* AccessResultData accessResultData = new AccessResultData();
* accessResultData.setPK...(value); // required
* // if exclusive control, the value of concurrency column is required
* accessResultData.setVersionNo(value);
* try {
* accessResultDataBhv.delete(accessResultData);
* } catch (EntityAlreadyUpdatedException e) { // if concurrent update
* ...
* }
*
* @param accessResultData The entity of delete. (NotNull, PrimaryKeyNotNull)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
*/
public void delete(AccessResultData accessResultData) {
doDelete(accessResultData, null);
}
// ===================================================================================
// Batch Update
// ============
/**
* Batch-insert the entity list modified-only of same-set columns. (DefaultConstraintsEnabled)
* This method uses executeBatch() of java.sql.PreparedStatement.
* The columns of least common multiple are registered like this:
*
* for (... : ...) {
* AccessResultData accessResultData = new AccessResultData();
* accessResultData.setFooName("foo");
* if (...) {
* accessResultData.setFooPrice(123);
* }
* // FOO_NAME and FOO_PRICE (and record meta columns) are registered
* // FOO_PRICE not-called in any entities are registered as null without default value
* // columns not-called in all entities are registered as null or default value
* accessResultDataList.add(accessResultData);
* }
* accessResultDataBhv.batchInsert(accessResultDataList);
*
* While, when the entities are created by select, all columns are registered.
* And if the table has an identity, entities after the process don't have incremented values.
* (When you use the (normal) insert(), you can get the incremented value from your entity)
* @param accessResultDataList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNullAllowed: when auto-increment)
* @return The array of inserted count. (NotNull, EmptyAllowed)
*/
public int[] batchInsert(List accessResultDataList) {
return doBatchInsert(accessResultDataList, null);
}
/**
* Batch-update the entity list modified-only of same-set columns. (NonExclusiveControl)
* This method uses executeBatch() of java.sql.PreparedStatement.
* You should specify same-set columns to all entities like this:
*
* for (... : ...) {
* AccessResultData accessResultData = new AccessResultData();
* accessResultData.setFooName("foo");
* if (...) {
* accessResultData.setFooPrice(123);
* } else {
* accessResultData.setFooPrice(null); // updated as null
* //accessResultData.setFooDate(...); // *not allowed, fragmented
* }
* // FOO_NAME and FOO_PRICE (and record meta columns) are updated
* // (others are not updated: their values are kept)
* accessResultDataList.add(accessResultData);
* }
* accessResultDataBhv.batchUpdate(accessResultDataList);
*
* @param accessResultDataList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNotNull)
* @return The array of updated count. (NotNull, EmptyAllowed)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
*/
public int[] batchUpdate(List accessResultDataList) {
return doBatchUpdate(accessResultDataList, null);
}
/**
* Batch-delete the entity list. (NonExclusiveControl)
* This method uses executeBatch() of java.sql.PreparedStatement.
* @param accessResultDataList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNotNull)
* @return The array of deleted count. (NotNull, EmptyAllowed)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
*/
public int[] batchDelete(List accessResultDataList) {
return doBatchDelete(accessResultDataList, null);
}
// ===================================================================================
// Query Update
// ============
/**
* Insert the several entities by query (modified-only for fixed value).
*
* accessResultDataBhv.queryInsert(new QueryInsertSetupper<AccessResultData, AccessResultDataCB>() {
* public ConditionBean setup(AccessResultData entity, AccessResultDataCB intoCB) {
* FooCB cb = FooCB();
* cb.setupSelect_Bar();
*
* // mapping
* intoCB.specify().columnMyName().mappedFrom(cb.specify().columnFooName());
* intoCB.specify().columnMyCount().mappedFrom(cb.specify().columnFooCount());
* intoCB.specify().columnMyDate().mappedFrom(cb.specify().specifyBar().columnBarDate());
* entity.setMyFixedValue("foo"); // fixed value
* // you don't need to set values of common columns
* //entity.setRegisterUser(value);
* //entity.set...;
* // you don't need to set a value of concurrency column
* //entity.setVersionNo(value);
*
* return cb;
* }
* });
*
* @param manyArgLambda The callback to set up query-insert. (NotNull)
* @return The inserted count.
*/
public int queryInsert(QueryInsertSetupper manyArgLambda) {
return doQueryInsert(manyArgLambda, null);
}
/**
* Update the several entities by query non-strictly modified-only. (NonExclusiveControl)
*
* AccessResultData accessResultData = new AccessResultData();
* // you don't need to set PK value
* //accessResultData.setPK...(value);
* accessResultData.setFoo...(value); // you should set only modified columns
* // you don't need to set values of common columns
* //accessResultData.setRegisterUser(value);
* //accessResultData.set...;
* // you don't need to set a value of concurrency column
* // (auto-increment for version number is valid though non-exclusive control)
* //accessResultData.setVersionNo(value);
* accessResultDataBhv.queryUpdate(accessResultData, cb -> {
* cb.query().setFoo...
* });
*
* @param accessResultData The entity that contains update values. (NotNull, PrimaryKeyNullAllowed)
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The updated count.
* @throws NonQueryUpdateNotAllowedException When the query has no condition.
*/
public int queryUpdate(AccessResultData accessResultData, CBCall cbLambda) {
return doQueryUpdate(accessResultData, createCB(cbLambda), null);
}
/**
* Delete the several entities by query. (NonExclusiveControl)
*
* accessResultDataBhv.queryDelete(accessResultData, cb -> {
* cb.query().setFoo...
* });
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @return The deleted count.
* @throws NonQueryDeleteNotAllowedException When the query has no condition.
*/
public int queryDelete(CBCall cbLambda) {
return doQueryDelete(createCB(cbLambda), null);
}
// ===================================================================================
// Varying Update
// ==============
// -----------------------------------------------------
// Entity Update
// -------------
/**
* Insert the entity with varying requests.
* For example, disableCommonColumnAutoSetup(), disablePrimaryKeyIdentity().
* Other specifications are same as insert(entity).
*
* AccessResultData accessResultData = new AccessResultData();
* // if auto-increment, you don't need to set the PK value
* accessResultData.setFoo...(value);
* accessResultData.setBar...(value);
* accessResultDataBhv.varyingInsert(accessResultData, op -> {
* // you can insert by your values for common columns
* op.disableCommonColumnAutoSetup();
* });
* ... = accessResultData.getPK...(); // if auto-increment, you can get the value after
*
* @param accessResultData The entity of insert. (NotNull, PrimaryKeyNullAllowed: when auto-increment)
* @param opLambda The callback for option of insert for varying requests. (NotNull)
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void varyingInsert(AccessResultData accessResultData, WritableOptionCall> opLambda) {
doInsert(accessResultData, createInsertOption(opLambda));
}
/**
* Update the entity with varying requests modified-only. (ZeroUpdateException, NonExclusiveControl)
* For example, self(selfCalculationSpecification), specify(updateColumnSpecification), disableCommonColumnAutoSetup().
* Other specifications are same as update(entity).
*
* AccessResultData accessResultData = new AccessResultData();
* accessResultData.setPK...(value); // required
* accessResultData.setOther...(value); // you should set only modified columns
* // if exclusive control, the value of concurrency column is required
* accessResultData.setVersionNo(value);
* // you can update by self calculation values
* accessResultDataBhv.varyingUpdate(accessResultData, op -> {
* op.self(cb -> {
* cb.specify().columnXxxCount();
* }).plus(1); // XXX_COUNT = XXX_COUNT + 1
* });
*
* @param accessResultData The entity of update. (NotNull, PrimaryKeyNotNull)
* @param opLambda The callback for option of update for varying requests. (NotNull)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void varyingUpdate(AccessResultData accessResultData, WritableOptionCall> opLambda) {
doUpdate(accessResultData, createUpdateOption(opLambda));
}
/**
* Insert or update the entity with varying requests. (ExclusiveControl: when update)
* Other specifications are same as insertOrUpdate(entity).
* @param accessResultData The entity of insert or update. (NotNull)
* @param insertOpLambda The callback for option of insert for varying requests. (NotNull)
* @param updateOpLambda The callback for option of update for varying requests. (NotNull)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void varyingInsertOrUpdate(AccessResultData accessResultData, WritableOptionCall> insertOpLambda, WritableOptionCall> updateOpLambda) {
doInsertOrUpdate(accessResultData, createInsertOption(insertOpLambda), createUpdateOption(updateOpLambda));
}
/**
* Delete the entity with varying requests. (ZeroUpdateException, NonExclusiveControl)
* Now a valid option does not exist.
* Other specifications are same as delete(entity).
* @param accessResultData The entity of delete. (NotNull, PrimaryKeyNotNull, ConcurrencyColumnNotNull)
* @param opLambda The callback for option of delete for varying requests. (NotNull)
* @throws EntityAlreadyDeletedException When the entity has already been deleted. (not found)
* @throws EntityDuplicatedException When the entity has been duplicated.
*/
public void varyingDelete(AccessResultData accessResultData, WritableOptionCall> opLambda) {
doDelete(accessResultData, createDeleteOption(opLambda));
}
// -----------------------------------------------------
// Batch Update
// ------------
/**
* Batch-insert the list with varying requests.
* For example, disableCommonColumnAutoSetup()
* , disablePrimaryKeyIdentity(), limitBatchInsertLogging().
* Other specifications are same as batchInsert(entityList).
* @param accessResultDataList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNotNull)
* @param opLambda The callback for option of insert for varying requests. (NotNull)
* @return The array of updated count. (NotNull, EmptyAllowed)
*/
public int[] varyingBatchInsert(List accessResultDataList, WritableOptionCall> opLambda) {
return doBatchInsert(accessResultDataList, createInsertOption(opLambda));
}
/**
* Batch-update the list with varying requests.
* For example, self(selfCalculationSpecification), specify(updateColumnSpecification)
* , disableCommonColumnAutoSetup(), limitBatchUpdateLogging().
* Other specifications are same as batchUpdate(entityList).
* @param accessResultDataList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNotNull)
* @param opLambda The callback for option of update for varying requests. (NotNull)
* @return The array of updated count. (NotNull, EmptyAllowed)
*/
public int[] varyingBatchUpdate(List accessResultDataList, WritableOptionCall> opLambda) {
return doBatchUpdate(accessResultDataList, createUpdateOption(opLambda));
}
/**
* Batch-delete the list with varying requests.
* For example, limitBatchDeleteLogging().
* Other specifications are same as batchDelete(entityList).
* @param accessResultDataList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNotNull)
* @param opLambda The callback for option of delete for varying requests. (NotNull)
* @return The array of deleted count. (NotNull, EmptyAllowed)
*/
public int[] varyingBatchDelete(List accessResultDataList, WritableOptionCall> opLambda) {
return doBatchDelete(accessResultDataList, createDeleteOption(opLambda));
}
// -----------------------------------------------------
// Query Update
// ------------
/**
* Insert the several entities by query with varying requests (modified-only for fixed value).
* For example, disableCommonColumnAutoSetup(), disablePrimaryKeyIdentity().
* Other specifications are same as queryInsert(entity, setupper).
* @param manyArgLambda The set-upper of query-insert. (NotNull)
* @param opLambda The callback for option of insert for varying requests. (NotNull)
* @return The inserted count.
*/
public int varyingQueryInsert(QueryInsertSetupper manyArgLambda, WritableOptionCall> opLambda) {
return doQueryInsert(manyArgLambda, createInsertOption(opLambda));
}
/**
* Update the several entities by query with varying requests non-strictly modified-only. {NonExclusiveControl}
* For example, self(selfCalculationSpecification), specify(updateColumnSpecification)
* , disableCommonColumnAutoSetup(), allowNonQueryUpdate().
* Other specifications are same as queryUpdate(entity, cb).
*
* // ex) you can update by self calculation values
* AccessResultData accessResultData = new AccessResultData();
* // you don't need to set PK value
* //accessResultData.setPK...(value);
* accessResultData.setOther...(value); // you should set only modified columns
* // you don't need to set a value of concurrency column
* // (auto-increment for version number is valid though non-exclusive control)
* //accessResultData.setVersionNo(value);
* accessResultDataBhv.varyingQueryUpdate(accessResultData, cb -> {
* cb.query().setFoo...
* }, op -> {
* op.self(colCB -> {
* colCB.specify().columnFooCount();
* }).plus(1); // FOO_COUNT = FOO_COUNT + 1
* });
*
* @param accessResultData The entity that contains update values. (NotNull) {PrimaryKeyNotRequired}
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @param opLambda The callback for option of update for varying requests. (NotNull)
* @return The updated count.
* @throws NonQueryUpdateNotAllowedException When the query has no condition (if not allowed).
*/
public int varyingQueryUpdate(AccessResultData accessResultData, CBCall cbLambda, WritableOptionCall> opLambda) {
return doQueryUpdate(accessResultData, createCB(cbLambda), createUpdateOption(opLambda));
}
/**
* Delete the several entities by query with varying requests non-strictly.
* For example, allowNonQueryDelete().
* Other specifications are same as queryDelete(cb).
*
* accessResultDataBhv.queryDelete(accessResultData, cb -> {
* cb.query().setFoo...
* }, op -> {
* op...
* });
*
* @param cbLambda The callback for condition-bean of AccessResultData. (NotNull)
* @param opLambda The callback for option of delete for varying requests. (NotNull)
* @return The deleted count.
* @throws NonQueryDeleteNotAllowedException When the query has no condition (if not allowed).
*/
public int varyingQueryDelete(CBCall cbLambda, WritableOptionCall> opLambda) {
return doQueryDelete(createCB(cbLambda), createDeleteOption(opLambda));
}
// ===================================================================================
// OutsideSql
// ==========
/**
* Prepare the all facade executor of outside-SQL to execute it.
*
* // main style
* accessResultDataBhv.outideSql().selectEntity(pmb); // optional
* accessResultDataBhv.outideSql().selectList(pmb); // ListResultBean
* accessResultDataBhv.outideSql().selectPage(pmb); // PagingResultBean
* accessResultDataBhv.outideSql().selectPagedListOnly(pmb); // ListResultBean
* accessResultDataBhv.outideSql().selectCursor(pmb, handler); // (by handler)
* accessResultDataBhv.outideSql().execute(pmb); // int (updated count)
* accessResultDataBhv.outideSql().call(pmb); // void (pmb has OUT parameters)
*
* // traditional style
* accessResultDataBhv.outideSql().traditionalStyle().selectEntity(path, pmb, entityType);
* accessResultDataBhv.outideSql().traditionalStyle().selectList(path, pmb, entityType);
* accessResultDataBhv.outideSql().traditionalStyle().selectPage(path, pmb, entityType);
* accessResultDataBhv.outideSql().traditionalStyle().selectPagedListOnly(path, pmb, entityType);
* accessResultDataBhv.outideSql().traditionalStyle().selectCursor(path, pmb, handler);
* accessResultDataBhv.outideSql().traditionalStyle().execute(path, pmb);
*
* // options
* accessResultDataBhv.outideSql().removeBlockComment().selectList()
* accessResultDataBhv.outideSql().removeLineComment().selectList()
* accessResultDataBhv.outideSql().formatSql().selectList()
*
* The invoker of behavior command should be not null when you call this method.
* @return The new-created all facade executor of outside-SQL. (NotNull)
*/
public OutsideSqlAllFacadeExecutor outsideSql() {
return doOutsideSql();
}
// ===================================================================================
// Type Helper
// ===========
protected Class extends AccessResultData> typeOfSelectedEntity() { return AccessResultData.class; }
protected Class typeOfHandlingEntity() { return AccessResultData.class; }
protected Class typeOfHandlingConditionBean() { return AccessResultDataCB.class; }
}