BEHAVIOR - The type of behavior.public class OutsideSqlTraditionalExecutor<BEHAVIOR> extends Object
| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected OutsideSqlBasicExecutor<BEHAVIOR> |
_basicExecutor
The basic executor.
|
| コンストラクタと説明 |
|---|
OutsideSqlTraditionalExecutor(OutsideSqlBasicExecutor<BEHAVIOR> basicExecutor) |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
protected BehaviorExceptionThrower |
createBhvExThrower() |
int |
execute(String path,
Object pmb)
Execute the outsideSql.
|
Object |
selectCursor(String path,
Object pmb,
CursorHandler handler)
Select the cursor of the entity by outside-SQL.
|
<ENTITY> OptionalEntity<ENTITY> |
selectEntity(String path,
Object pmb,
Class<ENTITY> entityType)
Select entity by the outside-SQL.
|
<ENTITY> ListResultBean<ENTITY> |
selectList(String path,
Object pmb,
Class<ENTITY> entityType)
Select the list of the entity by the outsideSql.
|
<ENTITY> PagingResultBean<ENTITY> |
selectPage(String path,
PagingBean pmb,
Class<ENTITY> entityType)
Select page by the outside-SQL.
|
<ENTITY> ListResultBean<ENTITY> |
selectPagedListOnly(String path,
PagingBean pmb,
Class<ENTITY> entityType)
Select list with paging by the outside-SQL.
|
protected final OutsideSqlBasicExecutor<BEHAVIOR> _basicExecutor
public OutsideSqlTraditionalExecutor(OutsideSqlBasicExecutor<BEHAVIOR> basicExecutor)
public <ENTITY> OptionalEntity<ENTITY> selectEntity(String path, Object pmb, Class<ENTITY> entityType)
String path = MemberBhv.PATH_selectSimpleMember;
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberId(3);
Class<SimpleMember> entityType = SimpleMember.class;
SimpleMember member
= memberBhv.outsideSql().entityHandling().selectEntity(path, pmb, entityType);
if (member != null) {
... = member.get...();
} else {
...
}
ENTITY - The type of entity.path - The path of SQL file. (NotNull)pmb - The object as parameter-bean. Allowed types are Bean object and Map object. (NullAllowed)entityType - The type of entity. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.EntityDuplicatedException - When the entity is duplicated.public <ENTITY> ListResultBean<ENTITY> selectList(String path, Object pmb, Class<ENTITY> entityType)
String path = MemberBhv.PATH_selectSimpleMember;
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
Class<SimpleMember> entityType = SimpleMember.class;
ListResultBean<SimpleMember> memberList
= memberBhv.outsideSql().selectList(path, pmb, entityType);
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.path - The path of SQL file. (NotNull)pmb - The object as parameter-bean. Allowed types are Bean object and Map object. (NullAllowed)entityType - The element type of entity. (NotNull)OutsideSqlNotFoundException - When the outsideSql is not found.DangerousResultSizeException - When the result size is over the specified safety size.public <ENTITY> PagingResultBean<ENTITY> selectPage(String path, PagingBean pmb, Class<ENTITY> entityType)
String path = MemberBhv.PATH_selectSimpleMember;
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
pmb.paging(20, 3); // 20 records per a page and current page number is 3
Class<SimpleMember> entityType = SimpleMember.class;
PagingResultBean<SimpleMember> page
= memberBhv.outsideSql().manualPaging().selectPage(path, pmb, entityType);
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.path - The path of SQL that executes count and paging. (NotNull)pmb - The bean of paging parameter. (NotNull)entityType - The type of result entity. (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(String path, PagingBean pmb, Class<ENTITY> entityType)
String path = MemberBhv.PATH_selectSimpleMember;
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
pmb.paging(20, 3); // 20 records per a page and current page number is 3
Class<SimpleMember> entityType = SimpleMember.class;
ListResultBean<SimpleMember> memberList
= memberBhv.outsideSql().manualPaging().selectList(path, pmb, entityType);
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.path - The path of SQL that executes count and paging. (NotNull)pmb - The bean of paging parameter. (NotNull)entityType - The type of result entity. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.DangerousResultSizeException - When the result size is over the specified safety size.public Object selectCursor(String path, Object pmb, CursorHandler handler)
String path = MemberBhv.PATH_selectSimpleMember;
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberName_PrefixSearch("S");
memberBhv.outsideSql().cursorHandling()
.selectCursor(path, 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+
path - The path of SQL file. (NotNull)pmb - The object as parameter-bean. Allowed types are Bean object and Map object. (NullAllowed)handler - The handler of cursor called back with result set. (NotNull)OutsideSqlNotFoundException - When the outside-SQL is not found.public int execute(String path, Object pmb)
String path = MemberBhv.PATH_selectSimpleMember;
SimpleMemberPmb pmb = new SimpleMemberPmb();
pmb.setMemberId(3);
int count = memberBhv.outsideSql().execute(path, pmb);
path - The path of SQL file. (NotNull)pmb - The parameter-bean. Allowed types are Bean object and Map object. (NullAllowed)OutsideSqlNotFoundException - When the outsideSql is not found.protected BehaviorExceptionThrower createBhvExThrower()
Copyright © 2014–2015 The DBFlute Project. All rights reserved.