public SqlMapExecutorDelegate getDelegate() { return client.getDelegate(); }
public SqlMapExecutorDelegate getDelegate() { return client.getDelegate(); }
public SqlMapRepositoryFactory(SqlMapClient sqlMapClient) { Assert.notNull(sqlMapClient, "SqlMapClient must not be null!"); this.sqlMapClient = (SqlMapClientImpl) sqlMapClient; this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient); if(ExtendedSqlMapClient.class.isAssignableFrom(sqlMapClient.getClass())) { this.sqlMapExecutorDelegate = ((ExtendedSqlMapClient) sqlMapClient).getDelegate(); } else if(hasSqlMapExecutorDelegate(sqlMapClient)) { Field field = findSqlMapExecutorDelegate(sqlMapClient); field.setAccessible(true); this.sqlMapExecutorDelegate = (SqlMapExecutorDelegate) ReflectionUtils.getField(field, sqlMapClient); } else { throw new IllegalArgumentException("not found SqlMapExecutorDelegate in SqlMapClient."); } }
/** * Apply the given iBATIS TransactionConfig to the SqlMapClient. * <p>Default implementation casts to ExtendedSqlMapClient, retrieves the maximum * number of concurrent transactions from the SqlMapExecutorDelegate, and sets * an iBATIS TransactionManager with the given TransactionConfig. * @param sqlMapClient the SqlMapClient to apply the TransactionConfig to * @param transactionConfig the iBATIS TransactionConfig to apply * @see com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient * @see com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate#getMaxTransactions * @see com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate#setTxManager */ protected void applyTransactionConfig(SqlMapClient sqlMapClient, TransactionConfig transactionConfig) { if (!(this.sqlMapClient instanceof ExtendedSqlMapClient)) { throw new IllegalArgumentException( "Cannot set TransactionConfig with DataSource for SqlMapClient if not of type " + "ExtendedSqlMapClient: " + this.sqlMapClient); } ExtendedSqlMapClient extendedClient = (ExtendedSqlMapClient) this.sqlMapClient; transactionConfig.setMaximumConcurrentTransactions(extendedClient.getDelegate().getMaxTransactions()); extendedClient.getDelegate().setTxManager(new TransactionManager(transactionConfig)); }
public PaginatedList queryForPaginatedList( final String statementName, final Object parameterObject, final int pageSize) throws DataAccessException { // throw exception if lazy loading will not work if (this.sqlMapClient instanceof ExtendedSqlMapClient && ((ExtendedSqlMapClient) this.sqlMapClient).getDelegate().getTxManager() == null) { throw new InvalidDataAccessApiUsageException( "SqlMapClient needs to have DataSource to allow for lazy loading" + " - specify SqlMapClientFactoryBean's 'dataSource' property"); } return (PaginatedList) execute(new SqlMapClientCallback() { public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException { return executor.queryForPaginatedList(statementName, parameterObject, pageSize); } }); }
protected IndexEntity[] doGetIndexEntities() throws CompassGpsException { ExtendedSqlMapClient extSqlMapClient = (ExtendedSqlMapClient) sqlMapClient; IndexEntity[] entities = new IndexEntity[selectStatementsIds.length]; for (int i = 0; i < selectStatementsIds.length; i++) { String statementId = selectStatementsIds[i]; MappedStatement statement = extSqlMapClient.getDelegate().getMappedStatement(statementId); if (statement == null) { throw new IllegalArgumentException("Failed to find statement for [" + statementId + "]"); } Class resultClass = statement.getResultMap().getResultClass(); ResourceMapping resourceMapping = ((CompassGpsInterfaceDevice) getGps()).getMappingForEntityForIndex(resultClass); if (resourceMapping == null) { throw new IllegalArgumentException("Failed to find mapping for class [" + resultClass.getName() + "]"); } Object parameterObject = null; if (statementsParameterObjects != null) { parameterObject = statementsParameterObjects[i]; } entities[i] = new SqlMapIndexEntity(resultClass.getName(), resourceMapping.getSubIndexHash().getSubIndexes(), statementId, parameterObject); } return entities; }