This ValueListAdapter returns a ValueList of wrapped records from ResultSet.

Using wrappers is recommended in cases, when your hibernate hql is too complex, and you cannot controll all composite joins. Then you would appreciate jdbc with the conjuction of wrappers that allow you to call third party managers, that return you wanted object. Wrappers helps you to replace the orignal ResultSet with wrapped record and still support paging. Sorting could be problematic due to replacement of records. But it is possible, depends on you!


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.
  • null Normal behaviour of ResultSet.
  • otherwise Create a ResultSetDecorator that controll every record in JVM. You can use it as a postretrieving "security" controller.
wrapperYN/A Replace orignal record with wrapped record.
wrapResultSetNfalse Determine object to be wrapped - resultSet or column from result set.

Example of the wrapper implementation

To use DefaultWrapperAdapter you have to

  1. Implement the net.mlw.vlh.adapter.util.ObjectWrapper interface.
    public class PlayersWrapper implements ObjectWrapper
        private PlayerManager playerManager;
        public Object getWrappedRecord(Object objectToBeWrapped)
    		Long id  = (Long) objectToBeWrapped;
    	    return playerManager.getPlayer(id);
    	 * @see net.mlw.vlh.adapter.util.ObjectWrapper#setValueListInfo(net.mlw.vlh.ValueListInfo)
        public void setValueListInfo(ValueListInfo info)
            // This method is called by adapter!
            // In this example is it not used, you can use it as additional way how
            // to pass some additional parameters to method isAcceptable.
  2. Than you have to create adapter bean in your applicationContext.xml
    <bean id="valueListHandler" singleton="true"  class="net.mlw.vlh.DefaultValueListHandlerImpl">
      <property name="config.adapters">
    		<entry key="nbaPlayersWrapper">
              <bean class="net.mlw.vlh.adapter.jdbc.objectWrapper.DefaultWrapperAdapter">
                <property name="dataSource"><ref bean="myDataSource"/></property>
                <property name="defaultNumberPerPage"><value>20</value></property>
                <property name="defaultSortColumn"><value>playerId</value></property>
                <property name="defaultSortDirection"><value>asc</value></property>
                <property name="sql">
    						      p.PLAYER_ID    as playerId						    
    						    FROM player p
    						    /~sortColumn: ORDER BY [sortColumn] [sortDirection]~/
    			<!-- this validator is optional see war example where is it used
    			<property name="validator"><ref bean="playersIdValidator"/></property>
    			<property name="wrapper"><ref bean="playersIdWrapper"/></property>
                <property name="wrapResultSet"><value>false</value></property>
    <bean id="playersIdWrapper" class="my.package.PlayersWrapper"/>

As you can see, we used the first variant of usage of DefautlWrapperAdapter. Another is to wrap instead of the given column, whole ResultSet. You can enable this with the property wrapResultSet by setting it to true.

For more details see war example version (0-1-7Beta11 or higher).