Seasar DI Container with AOP

S2DaoExercise

This exercise will check on your knowledge of S2Dao. Check the correct statement and select the "Check" button below.

JavaBeans

[Question 1]
When the class name of the JavaBeans is Employee and table name is EMP, which of the statement below is the correct declaration to associate JavaBeans to the table?
Hint: TABLE Annotation

1). public static final String Employee_TABLE = "EMP";
2). public static final String TABLE = "Employee_EMP";
3). public static final String TABLE = "EMP";
4). private static final String TABLE = "EMP";

[Question 2]
When the property name is employeeNo and the column name in the EMP table is EMPNO, which of the statement below is the correct constant declaration?
Hint: COLUMN Annotation

1). public static final String employeeNo = "EMPNO";
2). private static final String employeeNo_COLUMN = "EMPNO";
3). public static final String employeeNo_COLUMN = "EMPNO";
4). public final String employeeNo_COLUMN = "EMPNO";

[Question 3]
When the property name is ename and the column name in the EMP table is ENAME, which of the statment below is the correct constant declaration?
Hint:COLUMN Annotation

1). public static final String ename_EMP = "ENAME";
2). public static final String ename = "EMP_ENAME";
3). public static final String ename = "ENAME_COLUMN";
4). It is not necessary to declare.

[Question 4]
When EMP table and SEC, DEPT tables are mapped N:1, which of the statement below is the correct RELNO constant declaration? Assume SEC table is associated with JavaBeans class Section. DEPT table is associated with JavaBeans class department.
Hint:N:1 Mapping

1). public static final int section_RELNO = 0; public static final int department_RELNO = 0;
2). public static final int section_RELNO = 0; public static final int department_RELNO = 1;
3). public static final String section_RELNO = "0"; public static final String department_RELNO = "1";
4). public static final int[ ] section_department_RELNO = {0,1};

[Question 5]
Which of the statement below is the correct RELKEYS constant declaration to associate DEPTNO column in EMP table with DEPTNO is DEPT table? Assume DEPTNO is the primary key in DEPT table.
Hint:N:1 Mapping

1). public static final String department = "DEPTNUM:DEPTNO";
2). public static final String department_RELKEYS = "DEPTNUM,DEPTNO";
3). public static final String department = "DEPTNO_RELKEYS";
4). It is not necessary to declare.

[Question 6]
Which of the statement below is the correct declaration to associate both DEPTNUM column in the EMP table with DEPTNO column in the DEPT table and DEPTKEY column in the EMP table with DEPTID column in the DEPT table?
Hint:N:1 Mapping

1). public static final String department_RELKEYS = "DEPTNUM:DEPTKEY,DEPTNO:DEPTID";
2). public static final String department_RELKEYS = "DEPTNUM:DEPTNO,DEPTKEY:DEPTID";
3). public static final String department_RELKEYS = "DEPTNUM,DEPTNO:DEPTKEY,DEPTID";
4). It is not necessary to declare.


Dao(Data Access Object)

[Question 1]
Which of the statement below is the correct declaration to associate EmployeeDao class with the Employee entity?
Hint:BEAN Annotation

1). public static final Class BEAN = Employee.class
2). public static final Class Employee = BEAN.class
3). public static final String BEAN = "Employee.class"
4). It isnot necessary to declare.

[Question 2]
When public Employee getEmployee(int employeeno) method is defined, which of the statement below is the correct ARGS annotation declaration? Assume column name of the table associated with method argument is empno.
Hint:ARGS Annotation

1). public static final String getEmployee_ARGS = "employeeno";
2). public static final String getEmployee_ARGS = "empno";
3). public static final String ARGS_getEmployee = "empno";
4). public static final String empno = "getEmployee_ARGS";

[Question 3]
When public List getEmployeeByJobDeptno(String job, Integer deptno) method is defined, which of the statement below is the correct ARGS annotation declaration? Assume column name of the table is the same as the method argument name.
Hint:ARGS Annotation

1). public String getEmployeeByJobDeptno_ARGS = "job:deptno";
2). public String getEmployeeByJobDeptno_ARGS = "job,deptno";
3). public String getEmployeeByJobDeptno_ARGS = "job deptno";
4). It is not recommended, but the declaration can be omitted.

[Question 4]
When public List getEmployeesBySal(Float minSal, Float maxSal) method that has arguments to limits the lower and upper salary (SAL) range is used to generate a SQL command, which of the QUERY annotation below will generate SQL command with a WHERE clause?
Hint:QUERY Annotation

1). public static final String getEmployeesBySal_QUERY =
"sal BETWEEN 'minSal' AND 'maxSal' ORDER BY empno";
2). public static final String getEmployeesBySal_QUERY =
"sal BETWEEN /*?*/ AND /*?*/ ORDER BY empno";
3). public static final String getEmployeesBySal_QUERY =
"sal BETWEEN ? AND ? ORDER BY empno";
4). It is not necessary to declare.

[Question 5]
Which statement below is the correct way to use QUERY Annotation in a SQL comment?
Hint:QUERY Annotation

1). public static final String getEmployees_QUERY =
"job = ?'CLERK'/*IF deptno != null*/ AND deptno = ?20/*END*/;
2). public static final String getEmployees_QUERY_SQLCOMMENT =
"job = /*job*/'CLERK'/*IF deptno != null*/ AND deptno = /*deptno*/20/*END*/";
3). public static final String getEmployees_QUERY =
"job = /*job*/'CLERK'/*IF deptno != null*/ AND deptno = /*deptno*/20/*END*/";
4). It is not possible to use QUERY annotation in a SQL comment.

[Question 6]
Which of the statement below is the incorrect method definition to Insert data?
Hint:Defining a Method

1). public void deptInsert(Department departmnt);
2). public void insert(Department department);
3). public int addDept(Department department);
4). public int createDept(Department department);

[Question 7]
Which of the statement below is the incorrect method definition to Update data?
Hint:Method Definition

1). public int update(Department department);
2). public int modifyDept(Department department);
3). public void storeDept(Department department);
4). public void commitDept(Department department);

[Question 8]
Which of the statement below is the incorrect method definition to Delete data?
Hint:Defining a Method

1). public int delete(Department department);
2). public String deleteDept(Department department);
3). public void removeDept(Department department);
4). public int removeDept(Department department);


[Question 1]
To use Dao, it is necessary to apply AOP to the registered Dao. Which of the statement below is the Interceptor to apply?
Hint:dicon file

1). TraceInterceptor
2). DelegateInterceptor
3). MockInterceptor
4). S2DaoInterceptor

[Question 2]
Which of the statement below is the correct dicon file definition? Assume S2DaoInterceptor is registered in dicon file dao.dicon.
Hint:dicon file

1).
<components>
    <include path="dao.dicon"/>
    <component class="example.dao.EmployeeDao"/>
</components>
2).
<components>
    <include path="dao.dicon"/>
    <component class="example.dao.EmployeeDao">
        <arg>dao.interceptor</arg>
    </component>
</components>
3).
<components>
    <component class="example.dao.EmployeeDao">
        <aspect>dao.interceptor</aspect>
    </component>
</components>
4).
<components>
    <include path="dao.dicon"/>
    <component class="example.dao.EmployeeDao">
        <aspect>dao.interceptor</aspect>
    </component>
</components>


SQL File

[Question 1]
Which of the file name below is the correct SQL file name to associate Employee method in EmployeeDao class with a SQL file?
Hint:SQL file

1). getEmployee.sql
2). EmployeeDao_getEmployee.sql
3). EmployeeDao.sql
4). getEmployee_EmployeeDao.sql


SQL Comment

[Question 1]
public String getEmployee_ARGS = "empno";
public List getEmployees(int empno);
When there is a Dao with the above ARGS annotation and a method which specifies the empno (employee number), which of the statements below is the correct usage of bind variable?
Hint:SQL Comment

1). SELECT * FROM emp WHERE empno = /*empno 7788*/
2). SELECT * FROM emp WHERE empno = 7788/*empno*/
3). SELECT * FROM emp WHERE empno = /*empno*/7788
4). SELECT * FROM emp WHERE empno = /* empno*/7788

[Question 2]
public String getEmployeeCommBy_ARGS = "comm";
public List getEmployeesByComm(Float comm);
When there is a Dao with the above ARGS annotation and a method which specifies the Comm (commission), which of statement below will create a SQL statement with the following conditions: If Comm is not null then set the condition to that Comm. If Comm is null, then set the condition to 0.
SELECT emp.*, dept.dname dname_0, dept.loc loc_0 FROM emp, dept WHERE emp.deptno = dept.deptno
Hint:SQL Comment

1). /*IF comm != null*/comm = /*comm*/300 -- ELSE comm = 0 /*END*/
2). /*and IF comm != null*/comm  = /*comm*/300 -- and ELSE comm = 0 /*END*/
3). /*IF comm != null*/ and comm = /*comm*/300 /*ELSE*/ and comm = 0 /*END*/
4). /*IF comm != null*/ and comm = /*comm*/300 -- ELSE and comm = 0 /*END*/

[Question 3]
SELECT * FROM EMP
/*BEGIN*/WHERE
/*IF job != null*/job = /*job*/'CLERK'/*END*/
/*IF deptno != null*/AND deptno = /*deptno*/20/*END*/
/*END*/
When the SQL file contains the above statements, which of the SQL statement below will be generated?
Hint:SQL Comment

1). SELECT * FROM EMP WHERE
2). SELECT * FROM EMP WHERE job = null and deptno = null
3). SELECT * FROM EMP
4). SQL文は発行されない


EntityManager

[Question 1]
Which of the class definition below will correctly use an EntityManager to execute a Query? Assume Dao is EmployeeDao interface.
Hint:Executing Query with EntityManager

1). public class EmployeeDaoImpl extends EmployeeDao implements AbstractDao
2). public class EmployeeDaoImpl extends AbstractDao implements EmployeeDao
3). public class EmployeeDaoImpl implements AbstractDao, EmployeeDao
4). public class EmployeeDaoImpl implements EmployeeDao

[Question 2]
When EntityManager method is used to excute a Query and there are more than 4 variables to bind, which of the statement below is correct?
Hint:Executing Query with EntityManager

1). public List findManyArgs(String query, Object arg1, Object arg2, Object arg3, Object arg4);
2). public List find(String query, Object arg1, Object arg2, Object arg3, Object arg4);
3). public List find(String query, Object[] args);
4). Only up to 3 variables may be bound to an EntityManager method.

[Question 3]
Which of the method below will return a List when EntityManager method is used?
Hint:Executing Query with EntityManager

1). public List findList(String query);
2). public List getList(String query);
3). public List find(String query);
4). public List get(String query);

[Question 4]
Which of the method below will return an array when EntityManager method is used?
Hint:Executing Query with EntityManager

1). public Object[] findArray(String query);
2). public Object[] getArray(String query);
3). public Object[] find(String query);
4). public Object[] get(String query);

[Question 5]
Which of the method below will return a JavaBeans when EntityManager method is used?
Hint:Executing Query with EntityManager

1). public Object getBean(String query);
2). public Object findJavaBeans(String query);
3). public Object get(String query);
4). public Object findBean(String query);

[Question 6]
Which of the method below will return one value, such as from a result from count(*), when EntityManager method is used?
Hint:Executing Query with EntityManager

1). public Object findBean(String query);
2). public Object findObject(String query);
 3). public Object getObject(String query);
4). public Object find(String query);


Automatic Generation of Update SQL

[Question 1]
Which of the statement below is correct when automatically generating update SQL statement?
Hint:Automatic Generation of Update SQL

1). It is not necessary to abide to the method naming convention
2). Any data type can be specified as a method return value.
3). Method argument must be JavaBeans.
4). SQL file is required.


Batch Update

[Question 1]
Which of the method definition will correctly automatically create update SQL statement and do a batch update?
Hint:Batch Update

1). public int insertBatch(Employee[] employees);
2). public Employee[] insertBatch();
3). public int insertBatch(Map map);
4). public int insertBatch(Employee employee);


Automatic Generation of Query SQL

[Question 1]
Which of the method definition below will automatically generate query SQL statement?
Hint:Automati Generation of Query SQL,Defining a Method

1). public Employee insertEmployee(Integer empno);
2). public String getEmployeeByEmpno(Integer empno);
3). public Employee getEmployeeByEmpno(Integer empno);
4). public Map getEmployeeByEmpno(Integer empno);

[Question 2]
SELECT * FROM EMP WHERE empno = /*empno*/7788
Which of the method definition below will automatically generate SQL statement similar to the manually written SQL statement above. Assume empno is a primary key.
Hint:Automatic Generation of Query SQL

1). public List getEmployees()
2). public Employee getEmployee()
3). private Employee getEmployeeByEmpno(int empno)
4). public Employee getEmployeeByEmpno(int empno)

[Question 3]
SELECT * FROM emp
/*BEGIN*/WHERE
/*IF deptno != null*/deptno = /*deptno*/20/*END*/
/*END*/
Which of the method definition below will automatically generate SQL statement similar to the manually written SQL statement above.
Hint:Automatic Generation of Query SQL

1). public List getEmployeesByDeptno()
2). public Employee getEmployeesByDeptno()
3). public List getEmployeeByDeptno(int deptno)
4). public List getEmployeeByDeptno(Integer deptno)