org.codelibs.fess.crawler.db.bsbhv.BsAccessResultBhv Maven / Gradle / Ivy
/*
* Copyright 2012-2015 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 as TABLE.
*
* [primary key]
* ID
*
* [column]
* ID, SESSION_ID, RULE_ID, URL, PARENT_URL, STATUS, HTTP_STATUS_CODE, METHOD, MIME_TYPE, CONTENT_LENGTH, EXECUTION_TIME, LAST_MODIFIED, CREATE_TIME
*
* [sequence]
*
*
* [identity]
* ID
*
* [version-no]
*
*
* [foreign table]
* ACCESS_RESULT_DATA(AsOne)
*
* [referrer table]
* ACCESS_RESULT_DATA
*
* [foreign property]
* accessResultDataAsOne
*
* [referrer property]
*
*
* @author DBFlute(AutoGenerator)
*/
public abstract class BsAccessResultBhv extends AbstractBehaviorWritable {
// ===================================================================================
// Definition
// ==========
/*df:beginQueryPath*/
/** Compare AccessResult with SessionIDs */
public static final String PATH_selectAccessResultListByUrlDiff = "selectAccessResultListByUrlDiff";
/** Delete AccessResult by SessionID */
public static final String PATH_deleteAccessResultBySessionId = "deleteAccessResultBySessionId";
/** Delete All AccessResult */
public static final String PATH_deleteAllAccessResult = "deleteAllAccessResult";
/*df:endQueryPath*/
// ===================================================================================
// DB Meta
// =======
/** {@inheritDoc} */
public AccessResultDbm asDBMeta() { return AccessResultDbm.getInstance(); }
/** {@inheritDoc} */
public String asTableDbName() { return "ACCESS_RESULT"; }
// ===================================================================================
// New Instance
// ============
/** {@inheritDoc} */
public AccessResultCB newConditionBean() { return new AccessResultCB(); }
// ===================================================================================
// 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 = accessResultBhv.selectCount(cb -> {
* cb.query().set...
* });
*
* @param cbLambda The callback for condition-bean of AccessResult. (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
* accessResultBhv.selectEntity(cb -> {
* cb.query().set...
* }).alwaysPresent(accessResult -> {
* // called if present, or exception
* ... = accessResult.get...
* });
*
* // if it might be no data, ...
* accessResultBhv.selectEntity(cb -> {
* cb.query().set...
* }).ifPresent(accessResult -> {
* // called if present
* ... = accessResult.get...
* }).orElse(() -> {
* // called if not present
* });
*
* @param cbLambda The callback for condition-bean of AccessResult. (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(AccessResultCB cb) {
return doSelectOptionalEntity(cb, typeOfSelectedEntity());
}
protected OptionalEntity doSelectOptionalEntity(AccessResultCB 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.
*
* AccessResult accessResult = accessResultBhv.selectEntityWithDeletedCheck(cb -> cb.acceptPK(1));
* ... = accessResult.get...(); // the entity always be not null
*
* @param cbLambda The callback for condition-bean of AccessResult. (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 AccessResult selectEntityWithDeletedCheck(CBCall cbLambda) {
return facadeSelectEntityWithDeletedCheck(createCB(cbLambda));
}
/**
* Select the entity by the primary-key value.
* @param id : PK, ID, NotNull, BIGINT(19). (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 AccessResultCB xprepareCBAsPK(Long id) {
assertObjectNotNull("id", id);
return newConditionBean().acceptPK(id);
}
// ===================================================================================
// List Select
// ===========
/**
* Select the list as result bean.
*
* ListResultBean<AccessResult> accessResultList = accessResultBhv.selectList(cb -> {
* cb.query().set...;
* cb.query().addOrderBy...;
* });
* for (AccessResult accessResult : accessResultList) {
* ... = accessResult.get...;
* }
*
* @param cbLambda The callback for condition-bean of AccessResult. (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<AccessResult> page = accessResultBhv.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 (AccessResult accessResult : page) {
* ... = accessResult.get...;
* }
*
* @param cbLambda The callback for condition-bean of AccessResult. (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.
*
* accessResultBhv.selectCursor(cb -> {
* cb.query().set...
* }, member -> {
* ... = member.getMemberName();
* });
*
* @param cbLambda The callback for condition-bean of AccessResult. (NotNull)
* @param entityLambda The handler of entity row of AccessResult. (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:
*
* accessResultBhv.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 accessResultList The entity list of accessResult. (NotNull)
* @param loaderLambda The callback to handle the referrer loader for actually loading referrer. (NotNull)
*/
public void load(List accessResultList, ReferrerLoaderHandler loaderLambda) {
xassLRArg(accessResultList, loaderLambda);
loaderLambda.handle(new LoaderOfAccessResult().ready(accessResultList, _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 accessResult The entity of accessResult. (NotNull)
* @param loaderLambda The callback to handle the referrer loader for actually loading referrer. (NotNull)
*/
public void load(AccessResult accessResult, ReferrerLoaderHandler loaderLambda) {
xassLRArg(accessResult, loaderLambda);
loaderLambda.handle(new LoaderOfAccessResult().ready(xnewLRAryLs(accessResult), _behaviorSelector));
}
// ===================================================================================
// Pull out Relation
// =================
/**
* Pull out the list of referrer-as-one table 'AccessResultData'.
* @param accessResultList The list of accessResult. (NotNull, EmptyAllowed)
* @return The list of referrer-as-one table. (NotNull, EmptyAllowed, NotNullElement)
*/
public List pulloutAccessResultDataAsOne(List accessResultList)
{ return helpPulloutInternally(accessResultList, "accessResultDataAsOne"); }
// ===================================================================================
// Extract Column
// ==============
/**
* Extract the value list of (single) primary key id.
* @param accessResultList The list of accessResult. (NotNull, EmptyAllowed)
* @return The list of the column value. (NotNull, EmptyAllowed, NotNullElement)
*/
public List extractIdList(List accessResultList)
{ return helpExtractListInternally(accessResultList, "id"); }
// ===================================================================================
// Entity Update
// =============
/**
* Insert the entity modified-only. (DefaultConstraintsEnabled)
*
* AccessResult accessResult = new AccessResult();
* // if auto-increment, you don't need to set the PK value
* accessResult.setFoo...(value);
* accessResult.setBar...(value);
* // you don't need to set values of common columns
* //accessResult.setRegisterUser(value);
* //accessResult.set...;
* accessResultBhv.insert(accessResult);
* ... = accessResult.getPK...(); // if auto-increment, you can get the value after
*
* While, when the entity is created by select, all columns are registered.
* @param accessResult The entity of insert. (NotNull, PrimaryKeyNullAllowed: when auto-increment)
* @throws EntityAlreadyExistsException When the entity already exists. (unique constraint violation)
*/
public void insert(AccessResult accessResult) {
doInsert(accessResult, null);
}
/**
* Update the entity modified-only. (ZeroUpdateException, NonExclusiveControl)
* By PK as default, and also you can update by unique keys using entity's uniqueOf().
*
* AccessResult accessResult = new AccessResult();
* accessResult.setPK...(value); // required
* accessResult.setFoo...(value); // you should set only modified columns
* // you don't need to set values of common columns
* //accessResult.setRegisterUser(value);
* //accessResult.set...;
* // if exclusive control, the value of concurrency column is required
* accessResult.setVersionNo(value);
* accessResultBhv.update(accessResult);
*
* @param accessResult 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(AccessResult accessResult) {
doUpdate(accessResult, 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 accessResult 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(AccessResult accessResult) {
doInsertOrUpdate(accessResult, null, null);
}
/**
* Delete the entity. (ZeroUpdateException, NonExclusiveControl)
* By PK as default, and also you can delete by unique keys using entity's uniqueOf().
*
* AccessResult accessResult = new AccessResult();
* accessResult.setPK...(value); // required
* // if exclusive control, the value of concurrency column is required
* accessResult.setVersionNo(value);
* try {
* accessResultBhv.delete(accessResult);
* } catch (EntityAlreadyUpdatedException e) { // if concurrent update
* ...
* }
*
* @param accessResult 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(AccessResult accessResult) {
doDelete(accessResult, 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 (... : ...) {
* AccessResult accessResult = new AccessResult();
* accessResult.setFooName("foo");
* if (...) {
* accessResult.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
* accessResultList.add(accessResult);
* }
* accessResultBhv.batchInsert(accessResultList);
*
* 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 accessResultList The list of the entity. (NotNull, EmptyAllowed, PrimaryKeyNullAllowed: when auto-increment)
* @return The array of inserted count. (NotNull, EmptyAllowed)
*/
public int[] batchInsert(List accessResultList) {
return doBatchInsert(accessResultList, 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 (... : ...) {
* AccessResult accessResult = new AccessResult();
* accessResult.setFooName("foo");
* if (...) {
* accessResult.setFooPrice(123);
* } else {
* accessResult.setFooPrice(null); // updated as null
* //accessResult.setFooDate(...); // *not allowed, fragmented
* }
* // FOO_NAME and FOO_PRICE (and record meta columns) are updated
* // (others are not updated: their values are kept)
* accessResultList.add(accessResult);
* }
* accessResultBhv.batchUpdate(accessResultList);
*
* @param accessResultList 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 accessResultList) {
return doBatchUpdate(accessResultList, null);
}
/**
* Batch-delete the entity list. (NonExclusiveControl)
* This method uses executeBatch() of java.sql.PreparedStatement.
* @param accessResultList 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 accessResultList) {
return doBatchDelete(accessResultList, null);
}
// ===================================================================================
// Query Update
// ============
/**
* Insert the several entities by query (modified-only for fixed value).
*
* accessResultBhv.queryInsert(new QueryInsertSetupper<AccessResult, AccessResultCB>() {
* public ConditionBean setup(AccessResult entity, AccessResultCB 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)
*
* AccessResult accessResult = new AccessResult();
* // you don't need to set PK value
* //accessResult.setPK...(value);
* accessResult.setFoo...(value); // you should set only modified columns
* // you don't need to set values of common columns
* //accessResult.setRegisterUser(value);
* //accessResult.set...;
* // you don't need to set a value of concurrency column
* // (auto-increment for version number is valid though non-exclusive control)
* //accessResult.setVersionNo(value);
* accessResultBhv.queryUpdate(accessResult, cb -> {
* cb.query().setFoo...
* });
*
* @param accessResult The entity that contains update values. (NotNull, PrimaryKeyNullAllowed)
* @param cbLambda The callback for condition-bean of AccessResult. (NotNull)
* @return The updated count.
* @throws NonQueryUpdateNotAllowedException When the query has no condition.
*/
public int queryUpdate(AccessResult accessResult, CBCall cbLambda) {
return doQueryUpdate(accessResult, createCB(cbLambda), null);
}
/**
* Delete the several entities by query. (NonExclusiveControl)
*
* accessResultBhv.queryDelete(accessResult, cb -> {
* cb.query().setFoo...
* });
*
* @param cbLambda The callback for condition-bean of AccessResult. (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).
*
* AccessResult accessResult = new AccessResult();
* // if auto-increment, you don't need to set the PK value
* accessResult.setFoo...(value);
* accessResult.setBar...(value);
* accessResultBhv.varyingInsert(accessResult, op -> {
* // you can insert by your values for common columns
* op.disableCommonColumnAutoSetup();
* });
* ... = accessResult.getPK...(); // if auto-increment, you can get the value after
*
* @param accessResult 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(AccessResult accessResult, WritableOptionCall> opLambda) {
doInsert(accessResult, 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).
*
* AccessResult accessResult = new AccessResult();
* accessResult.setPK...(value); // required
* accessResult.setOther...(value); // you should set only modified columns
* // if exclusive control, the value of concurrency column is required
* accessResult.setVersionNo(value);
* // you can update by self calculation values
* accessResultBhv.varyingUpdate(accessResult, op -> {
* op.self(cb -> {
* cb.specify().columnXxxCount();
* }).plus(1); // XXX_COUNT = XXX_COUNT + 1
* });
*
* @param accessResult 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(AccessResult accessResult, WritableOptionCall> opLambda) {
doUpdate(accessResult, createUpdateOption(opLambda));
}
/**
* Insert or update the entity with varying requests. (ExclusiveControl: when update)
* Other specifications are same as insertOrUpdate(entity).
* @param accessResult 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(AccessResult accessResult, WritableOptionCall> insertOpLambda, WritableOptionCall> updateOpLambda) {
doInsertOrUpdate(accessResult, 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 accessResult 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(AccessResult accessResult, WritableOptionCall> opLambda) {
doDelete(accessResult, createDeleteOption(opLambda));
}
// -----------------------------------------------------
// Batch Update
// ------------
/**
* Batch-insert the list with varying requests.
* For example, disableCommonColumnAutoSetup()
* , disablePrimaryKeyIdentity(), limitBatchInsertLogging().
* Other specifications are same as batchInsert(entityList).
* @param accessResultList 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 accessResultList, WritableOptionCall> opLambda) {
return doBatchInsert(accessResultList, 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 accessResultList 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 accessResultList, WritableOptionCall> opLambda) {
return doBatchUpdate(accessResultList, createUpdateOption(opLambda));
}
/**
* Batch-delete the list with varying requests.
* For example, limitBatchDeleteLogging().
* Other specifications are same as batchDelete(entityList).
* @param accessResultList 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 accessResultList, WritableOptionCall> opLambda) {
return doBatchDelete(accessResultList, 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
* AccessResult accessResult = new AccessResult();
* // you don't need to set PK value
* //accessResult.setPK...(value);
* accessResult.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)
* //accessResult.setVersionNo(value);
* accessResultBhv.varyingQueryUpdate(accessResult, cb -> {
* cb.query().setFoo...
* }, op -> {
* op.self(colCB -> {
* colCB.specify().columnFooCount();
* }).plus(1); // FOO_COUNT = FOO_COUNT + 1
* });
*
* @param accessResult The entity that contains update values. (NotNull) {PrimaryKeyNotRequired}
* @param cbLambda The callback for condition-bean of AccessResult. (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(AccessResult accessResult, CBCall cbLambda, WritableOptionCall> opLambda) {
return doQueryUpdate(accessResult, 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).
*
* accessResultBhv.queryDelete(accessResult, cb -> {
* cb.query().setFoo...
* }, op -> {
* op...
* });
*
* @param cbLambda The callback for condition-bean of AccessResult. (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
* accessResultBhv.outideSql().selectEntity(pmb); // optional
* accessResultBhv.outideSql().selectList(pmb); // ListResultBean
* accessResultBhv.outideSql().selectPage(pmb); // PagingResultBean
* accessResultBhv.outideSql().selectPagedListOnly(pmb); // ListResultBean
* accessResultBhv.outideSql().selectCursor(pmb, handler); // (by handler)
* accessResultBhv.outideSql().execute(pmb); // int (updated count)
* accessResultBhv.outideSql().call(pmb); // void (pmb has OUT parameters)
*
* // traditional style
* accessResultBhv.outideSql().traditionalStyle().selectEntity(path, pmb, entityType);
* accessResultBhv.outideSql().traditionalStyle().selectList(path, pmb, entityType);
* accessResultBhv.outideSql().traditionalStyle().selectPage(path, pmb, entityType);
* accessResultBhv.outideSql().traditionalStyle().selectPagedListOnly(path, pmb, entityType);
* accessResultBhv.outideSql().traditionalStyle().selectCursor(path, pmb, handler);
* accessResultBhv.outideSql().traditionalStyle().execute(path, pmb);
*
* // options
* accessResultBhv.outideSql().removeBlockComment().selectList()
* accessResultBhv.outideSql().removeLineComment().selectList()
* accessResultBhv.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 AccessResult> typeOfSelectedEntity() { return AccessResult.class; }
protected Class typeOfHandlingEntity() { return AccessResult.class; }
protected Class typeOfHandlingConditionBean() { return AccessResultCB.class; }
}