DefaultDynclassAdapter

This adapter queries the the database and returns a ValueList of DynaBean(s).

Properties

NameRequiredDefaultDescription
adapterTypeN0 A bitwise OR of the following:
  • 1 If you want the sorting done in the JVM.
  • 2 If you want paging done in the JVM.
  • 4 If you want filtering done in the JVM.
dataSourceYN/AAn instance of javax.sql.DataSource.
sqlYN/AThe sql query.
defaultNumberPerPageNInteger.MAX_VALUE The number if items per page. This can be overridden by a value in the ValueListInfo.
defaultSortColumnNN/A The column to sort the results by. This can be overridden by a value in the ValueListInfo.
defaultSortDirectionNN/A The direction (asc or desc) to sort the results by. This can be overridden by a value in the ValueListInfo.
useNameNtrue
  • true Use the name of the column as the DynaBean property name.
  • false Use the name of the alias as the DynaBean property name. (hsqldb requires false)
validatorNnull
  • null Normal behaviour of ResultSet.
  • otherwise Create a ResultSetDecorator that controll every record in JVM. You can use it as a postretrieving "security" controller.

Sample config file.

You will notice the SQL in the <sql> tag is not valid SQL. The line: /~sortColumn: ORDER BY [sortColumn] [sortDirection]~/ contains chars '/', '~', '[' and ']'; all invalid chars in thier context. Let me explain what is hapening here.

The DefaultDynAdapter uses the values in the ValueListInfo.filters to dynamically build the query. The following rules are applied.

  • /~sortColumn: ~/ This is called a filter. The contents between the /~ and the ~/ are included only if the ValueListInfo.filters map contains the key 'sortColumn'.
  • [sortColumn] This is called a constant. The contents between the [ and the ] are replaced with the value in the ValueListInfo.filters map. For example:

    'ORDER BY [sortColumn] DESC' = 'ORDER BY my_sorted_column DESC'

  • {name} This is called a bind varable. The contents between the { and the } are replaced with a ?, then the value in the ValueListInfo.filters map is set on the PreparedStatement. For example:

    'WHERE user.name = {name}' = 'WHERE user.name = ?'