BEHAVIOR - The type of behavior.public class OutsideSqlAllFacadeExecutor<BEHAVIOR> extends Object
// main style memberBhv.outideSql().selectEntity(pmb); // OptionalEntity memberBhv.outideSql().selectList(pmb); // ListResultBean memberBhv.outideSql().selectPage(pmb); // PagingResultBean memberBhv.outideSql().selectPagedListOnly(pmb); // ListResultBean memberBhv.outideSql().selectCursor(pmb, handler); // (by handler) memberBhv.outideSql().execute(pmb); // int (updated count) memberBhv.outideSql().call(pmb); // void (pmb has OUT parameters) // traditional style memberBhv.outideSql().traditionalStyle().selectEntity(path, pmb, entityType); memberBhv.outideSql().traditionalStyle().selectList(path, pmb, entityType); memberBhv.outideSql().traditionalStyle().selectPage(path, pmb, entityType); memberBhv.outideSql().traditionalStyle().selectPagedListOnly(path, pmb, entityType); memberBhv.outideSql().traditionalStyle().selectCursor(path, pmb, handler); memberBhv.outideSql().traditionalStyle().execute(path, pmb); // options memberBhv.outideSql().removeBlockComment().selectList() memberBhv.outideSql().removeLineComment().selectList() memberBhv.outideSql().formatSql().selectList()
| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected OutsideSqlBasicExecutor<BEHAVIOR> |
_basicExecutor
The basic executor of outside-SQL.
|
| コンストラクタと説明 |
|---|
OutsideSqlAllFacadeExecutor(OutsideSqlBasicExecutor<BEHAVIOR> basicExecutor) |
protected final OutsideSqlBasicExecutor<BEHAVIOR> _basicExecutor
public OutsideSqlAllFacadeExecutor(OutsideSqlBasicExecutor<BEHAVIOR> basicExecutor)
public <ENTITY> OptionalEntity<ENTITY> selectEntity(EntityHandlingPmb<BEHAVIOR,ENTITY> pmb)
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberId(3);
SimpleMember member
= memberBhv.outsideSql().selectEntity(pmb);
if (member != null) {
... = member.get...();
} else {
...
}
ENTITY - The type of entity.pmb - The typed parameter-bean for entity handling. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.EntityDuplicatedException - When the entity is duplicated.public <ENTITY> ListResultBean<ENTITY> selectList(ListHandlingPmb<BEHAVIOR,ENTITY> pmb)
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
ListResultBean<SimpleMember> memberList
= memberBhv.outsideSql().selectList(pmb);
for (SimpleMember member : memberList) {
... = member.get...();
}
It needs to use customize-entity and parameter-bean.
The way to generate them is following:
-- #df:entity# -- !df:pmb! -- !!Integer memberId!! -- !!String memberName!! -- !!...!!
ENTITY - The type of entity for element.pmb - The typed parameter-bean for list handling. (NotNull)OutsideSqlNotFoundException - When the outsideSql is not found.DangerousResultSizeException - When the result size is over the specified safety size.public <ENTITY> PagingResultBean<ENTITY> selectPage(PagingHandlingPmb<BEHAVIOR,ENTITY> pmb)
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
pmb.paging(20, 3); // 20 records per a page and current page number is 3
PagingResultBean<SimpleMember> page
= memberBhv.outsideSql().selectPage(pmb);
int allRecordCount = page.getAllRecordCount();
int allPageCount = page.getAllPageCount();
boolean isExistPrePage = page.isExistPrePage();
boolean isExistNextPage = page.isExistNextPage();
...
for (SimpleMember member : page) {
... = member.get...();
}
The parameter-bean needs to extend SimplePagingBean.
The way to generate it is following:
-- !df:pmb extends Paging! -- !!Integer memberId!! -- !!...!!You can realize by pagingBean's isPaging() method on your 'Parameter Comment'. It returns false when it executes Count. And it returns true when it executes Paging.
e.g. ManualPaging and MySQL /*IF pmb.isPaging()*/ select member.MEMBER_ID , member.MEMBER_NAME , memberStatus.MEMBER_STATUS_NAME -- ELSE select count(*) /*END*/ from MEMBER member /*IF pmb.isPaging()*/ left outer join MEMBER_STATUS memberStatus on member.MEMBER_STATUS_CODE = memberStatus.MEMBER_STATUS_CODE /*END*/ /*BEGIN*/ where /*IF pmb.memberId != null*/ member.MEMBER_ID = /*pmb.memberId*/'123' /*END*/ /*IF pmb.memberName != null*/ and member.MEMBER_NAME like /*pmb.memberName*/'Billy%' /*END*/ /*END*/ /*IF pmb.isPaging()*/ order by member.UPDATE_DATETIME desc /*END*/ /*IF pmb.isPaging()*/ limit /*pmb.pageStartIndex*/80, /*pmb.fetchSize*/20 /*END*/
ENTITY - The type of entity.pmb - The typed parameter-bean for paging handling. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.DangerousResultSizeException - When the result size is over the specified safety size.public <ENTITY> ListResultBean<ENTITY> selectPagedListOnly(PagingHandlingPmb<BEHAVIOR,ENTITY> pmb)
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
pmb.paging(20, 3); // 20 records per a page and current page number is 3
ListResultBean<SimpleMember> memberList
= memberBhv.outsideSql().selectPagedListOnly(pmb);
for (SimpleMember member : memberList) {
... = member.get...();
}
The parameter-bean needs to extend SimplePagingBean.
The way to generate it is following:
-- !df:pmb extends Paging! -- !!Integer memberId!! -- !!...!!You don't need to use pagingBean's isPaging() method on your 'Parameter Comment'.
e.g. ManualPaging and MySQL
select member.MEMBER_ID
, member.MEMBER_NAME
, memberStatus.MEMBER_STATUS_NAME
from MEMBER member
left outer join MEMBER_STATUS memberStatus
on member.MEMBER_STATUS_CODE = memberStatus.MEMBER_STATUS_CODE
/*BEGIN*/
where
/*IF pmb.memberId != null*/
member.MEMBER_ID = /*pmb.memberId*/'123'
/*END*/
/*IF pmb.memberName != null*/
and member.MEMBER_NAME like /*pmb.memberName*/'Billy%'
/*END*/
/*END*/
order by member.UPDATE_DATETIME desc
limit /*pmb.pageStartIndex*/80, /*pmb.fetchSize*/20
ENTITY - The type of entity.pmb - The typed parameter-bean for paging handling. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.DangerousResultSizeException - When the result size is over the specified safety size.public <ENTITY> Object selectCursor(CursorHandlingPmb<BEHAVIOR,ENTITY> pmb, CursorHandler handler)
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
memberBhv.outsideSql().selectCursor(pmb, new PurchaseSummaryMemberCursorHandler() {
protected Object fetchCursor(PurchaseSummaryMemberCursor cursor) throws SQLException {
while (cursor.next()) {
Integer memberId = cursor.getMemberId();
String memberName = cursor.getMemberName();
...
}
return null;
}
});
It needs to use type-safe-cursor instead of customize-entity.
The way to generate it is following:
-- #df:entity# -- +cursor+
ENTITY - The type of entity, might be void.pmb - The typed parameter-bean for cursor handling. (NotNull)handler - The handler of cursor called back with result set. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.public int execute(ExecuteHandlingPmb<BEHAVIOR> pmb)
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberId(3);
int count = memberBhv.outsideSql().execute(pmb);
pmb - The parameter-bean. Allowed types are Bean object and Map object. (NullAllowed)OutsideSqlNotFoundException - When the outsideSql is not found.public void call(ProcedurePmb pmb)
SpInOutParameterPmb pmb = new SpInOutParameterPmb();
pmb.setVInVarchar("foo");
pmb.setVInOutVarchar("bar");
memberBhv.outsideSql().call(pmb);
String outVar = pmb.getVOutVarchar();
It needs to use parameter-bean for procedure (ProcedurePmb).
The way to generate is to set the option of DBFlute property and execute Sql2Entity.pmb - The parameter-bean for procedure. (NotNull)public OutsideSqlTraditionalExecutor<BEHAVIOR> traditionalStyle()
public OutsideSqlAllFacadeExecutor<BEHAVIOR> removeBlockComment()
public OutsideSqlAllFacadeExecutor<BEHAVIOR> removeLineComment()
public OutsideSqlAllFacadeExecutor<BEHAVIOR> formatSql()
public OutsideSqlAllFacadeExecutor<BEHAVIOR> configure(StatementConfigCall<StatementConfig> confLambda)
memberBhv.outsideSql().configure(conf -> conf.queryTimeout(3)).selectList(...);
confLambda - The callback for configuration of statement. (NotNull)protected void assertStatementConfigNotDuplicated(StatementConfigCall<StatementConfig> configCall)
protected StatementConfig createStatementConfig(StatementConfigCall<StatementConfig> configCall)
protected StatementConfig newStatementConfig()
protected BehaviorExceptionThrower createBhvExThrower()
public OutsideSqlBasicExecutor<BEHAVIOR> xbasicExecutor()
Copyright © 2014–2015 The DBFlute Project. All rights reserved.