1 ${database.allClassCopyright}package ${glPackageBaseCommonCBeanOutsidesqlExecutor};
\r
3 import java.util.List;
\r
5 #if (!$database.isCompatibleOutsideSqlResultOldStyle())
\r
6 import ${glPackageBaseCommonCBean}.${glListResultBeanName};
\r
7 import ${glPackageBaseCommonCBean}.${glResultBeanBuilderName};
\r
9 import ${glPackageBaseCommonCBeanOutsidesql}.${glOutsideSqlDaoName};
\r
10 import ${glPackageBaseCommonCBeanOutsidesql}.${glOutsideSqlOptionName};
\r
11 import ${glPackageBaseCommonCBeanOutsidesql}.${glProcedurePmbName};
\r
12 import ${glPackageBaseCommonJdbc}.${glStatementConfig};
\r
15 * The executor of outside-sql. <br />
\r
23 * o entityHandling().selectEntity()
\r
24 * o entityHandling().selectEntityWithDeletedCheck()
\r
27 * o cursorHandling().selectCursor()
\r
30 * o autoPaging().selectList()
\r
31 * o autoPaging().selectPage()
\r
32 * o manualPaging().selectList()
\r
33 * o manualPaging().selectPage()
\r
35 * {Option -- Dynamic}
\r
36 * o dynamicBinding().selectList()
\r
40 * @author ${database.ClassAuthor}
\r
42 public class ${glOutsideSqlBasicExecutorName} {
\r
44 // ===================================================================================
\r
47 /** The DAO of outside-sql. (NotNull) */
\r
48 protected final ${glOutsideSqlDaoName} _outsideSqlDao;
\r
50 /** Table DB name. (NotNull) */
\r
51 protected final String _tableDbName;
\r
53 /** Is it dynamic binding? */
\r
54 protected boolean _dynamicBinding;
\r
56 /** The config of statement. (Nullable) */
\r
57 protected ${glStatementConfig} _statementConfig;
\r
59 // ===================================================================================
\r
62 public ${glOutsideSqlBasicExecutorName}(${glOutsideSqlDaoName} outsideSqlDao, String tableDbName) {
\r
63 this._outsideSqlDao = outsideSqlDao;
\r
64 this._tableDbName = tableDbName;
\r
67 // ===================================================================================
\r
71 * Select the list of the entity.
\r
72 * @param <ENTITY> The type of entity for element.
\r
73 * @param path The path of SQL file. (NotNull)
\r
74 * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)
\r
75 * @param entityType The element type of entity. (NotNull)
\r
76 * @return The result bean of selected list. (NotNull)
\r
77 * @exception ${glPackageBaseCommonException}.${glOutsideSqlNotFoundException} When the outside-sql is not found.
\r
79 #if (!$database.isCompatibleOutsideSqlResultOldStyle())
\r
80 public <ENTITY> ${glListResultBeanName}<ENTITY> selectList(String path, Object pmb, Class<ENTITY> entityType) {
\r
81 List<ENTITY> resultList = _outsideSqlDao.selectList(path, pmb, createOutsideSqlOption(), entityType);
\r
82 return new ${glResultBeanBuilderName}<ENTITY>(_tableDbName).buildListResultBean(resultList);
\r
85 public <ENTITY> List<ENTITY> selectList(String path, Object pmb, Class<ENTITY> entityType) {
\r
86 return _outsideSqlDao.selectList(path, pmb, createOutsideSqlOption(), entityType);
\r
90 // ===================================================================================
\r
94 * Execute. {Insert/Update/Delete/Etc...}
\r
95 * @param path The path of SQL file. (NotNull)
\r
96 * @param pmb The parameter-bean. Allowed types are Bean object and Map object. (Nullable)
\r
97 * @return The count of execution.
\r
98 * @exception ${glPackageBaseCommonException}.${glOutsideSqlNotFoundException} When the outside-sql is not found.
\r
100 public int execute(String path, Object pmb) {
\r
101 return _outsideSqlDao.execute(path, pmb, createOutsideSqlOption());
\r
105 // ===================================================================================
\r
109 * Call stored procedure.
\r
110 * @param pmb The parameter-bean for procedure. (NotNull)
\r
112 public void call(${glProcedurePmbName} pmb) {
\r
113 if (pmb == null) { throw new IllegalArgumentException("The argument of call() 'pmb' should not be null!"); }
\r
114 _outsideSqlDao.call(pmb.getProcedureName(), pmb, createOutsideSqlOption());
\r
117 // ===================================================================================
\r
120 // -----------------------------------------------------
\r
124 * Specify cursor handling. <br />
\r
126 * # ex) Your Program
\r
128 * # executor.cursorHandling().selectCursor(path, pmb, handler);
\r
131 * @return The cursor executor of outside-sql. (NotNull)
\r
133 public ${glOutsideSqlCursorExecutorName}<Object> cursorHandling() {
\r
134 return new ${glOutsideSqlCursorExecutorName}<Object>(_outsideSqlDao, createOutsideSqlOption());
\r
138 * Specify entity handling. <br />
\r
140 * # ex) Your Program
\r
142 * # executor.entityHandling().selectEntityWithDeletedCheck(path, pmb, Xxx.class);
\r
145 * @return The cursor executor of outside-sql. (NotNull)
\r
147 public ${glOutsideSqlEntityExecutorName}<Object> entityHandling() {
\r
148 return new ${glOutsideSqlEntityExecutorName}<Object>(_outsideSqlDao, createOutsideSqlOption());
\r
151 // -----------------------------------------------------
\r
155 * Option of autoPaging. <br />
\r
156 * If you invoke this, you don't need to write paging condition on your SQL. <br />
\r
158 * # ex) Your SQL {MySQL}
\r
160 * # select member.MEMBER_ID, member...
\r
161 * # from Member member
\r
164 * # -- limit 40, 20 *Here is unnecessary!
\r
167 * @return The executor of paging that the paging mode is auto. (NotNull)
\r
169 public ${glOutsideSqlPagingExecutorName} autoPaging() {
\r
170 final ${glOutsideSqlOptionName} option = createOutsideSqlOption();
\r
171 option.autoPaging();
\r
172 return new ${glOutsideSqlPagingExecutorName}(_outsideSqlDao, option, _tableDbName);
\r
176 * Option of manualPaging. <br />
\r
177 * If you invoke this, you need to write paging condition on your SQL. <br />
\r
179 * # ex) Your SQL {MySQL}
\r
181 * # select member.MEMBER_ID, member...
\r
182 * # from Member member
\r
185 * # limit 40, 20 *Here is necessary!
\r
188 * @return The executor of paging that the paging mode is manual. (NotNull)
\r
190 public ${glOutsideSqlPagingExecutorName} manualPaging() {
\r
191 final ${glOutsideSqlOptionName} option = createOutsideSqlOption();
\r
192 option.manualPaging();
\r
193 return new ${glOutsideSqlPagingExecutorName}(_outsideSqlDao, option, _tableDbName);
\r
196 // -----------------------------------------------------
\r
199 public ${glOutsideSqlBasicExecutorName} dynamicBinding() {
\r
200 _dynamicBinding = true;
\r
204 // -----------------------------------------------------
\r
205 // Statement Config
\r
206 // ----------------
\r
207 public ${glOutsideSqlBasicExecutorName} configure(${glStatementConfig} statementConfig) {
\r
208 _statementConfig = statementConfig;
\r
212 // ===================================================================================
\r
215 protected ${glOutsideSqlOptionName} createOutsideSqlOption() {
\r
216 final ${glOutsideSqlOptionName} option = new ${glOutsideSqlOptionName}();
\r
217 option.setStatementConfig(_statementConfig);
\r
218 if (_dynamicBinding) {
\r
219 option.dynamicBinding();
\r
221 option.setTableDbName(_tableDbName);// as information
\r