Results 1 to 5 of 5

Thread: Problem with DB2 tablePrefix

  1. #1
    Join Date
    Feb 2010
    Posts
    4

    Default Problem with DB2 tablePrefix

    Hello
    I've run into a problem with the sample jUnit tests from spring batch 2.1.0 RC1

    I've changed the configuration from hsql to db2. When running the jUnit test DatabaseShutdownFunctionalTests, the tablePrefix is not set. When debugging the test, I see that the tableprefix from AbstractJdbcBatchMetadataDao is BATCH_, which later gets changed to userid.BATCH_. This will not work, as our tables have other prefixes.

    In other jUnit Tests like BeanWrapperMapperSampleJobFunctionalTests, CompositeItemWriterSampleFunctionalTests and CustomerFilterJobFunctionalTests the table prefix is set properly.

    I've set the table prefix in the jobRepository simple-job-launcher-context.xml:

    Code:
    <bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
    	    p:databaseType="db2" p:tablePrefix="DB2UTST.BATCH_"
    and in all jdbctemplates:

    Code:
    	@Override
    	public void afterRead(Long id) {
    		int count = jdbcTemplate.update("UPDATE DB2UTST.BATCH_STAGING SET PROCESSED=? WHERE ID=? AND PROCESSED=?",
    				StagingItemWriter.DONE, id, StagingItemWriter.NEW);

    Other than changing the default-prefix in the class AbstractJdbcBatchMetadataDao, is there a way to inject this property somewhere?

    Thanks a lot
    Lorenz

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    We never run the samples tests against a non-default table prefix as a CI build, so I'm not surprised it doesn't work. The core features should work though, if you write your own jobs, or cherry pick from the samples (as you already noticed). You can raise a JIRA if you like.

  3. #3
    Join Date
    Feb 2010
    Posts
    4

    Default

    Thanks, Dave
    I'll create an issue, especially because I had to tweak AbstractJdbcBatchMetadataDao when installing Spring-Batch-Admin (with the same DB2 database)

  4. #4
    Join Date
    Mar 2010
    Posts
    4

    Default

    I was able to hook up the Spring Batch Admin sample project with a MySQL database which uses a table prefix without modifying any Java code. I did this by overriding the jobRepository, jobExplorer, and jobService beans (setting tablePrefix property).

    It might only be possible to override the jobService bean in Spring Batch Admin 1.0.0.M2 and above as the jobService bean does not have an id in previous versions.

  5. #5
    Join Date
    Feb 2010
    Posts
    4

    Default

    Hello andrealee
    I forgot to set the tableprefix in the jobExplorer, see
    https://jira.springsource.org/browse/BATCH-1516.

    Everything is working now as expected.
    Thanks, Lorenzo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •