Skip to content

New JobParameter Types Required [BATCH-1581] #1983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jun 15, 2010 · 5 comments
Closed

New JobParameter Types Required [BATCH-1581] #1983

spring-projects-issues opened this issue Jun 15, 2010 · 5 comments
Labels
in: core status: declined Features that we don't intend to implement or Bug reports that are invalid or missing enough details type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

Tomasz Blachowicz opened BATCH-1581 and commented

Currently there is support only for the limited number of types of JobParameter. It is required that other primitive types such as Integer or Boolean are supported as well.

This would particularly useful when dealing with readers such as HibernateCursorItemReader. The reader can gives ability to provide the parameters to be bound to the query (prepared statement parameters). However there is no straightforward way to provide the Integer of Boolean values for parameters that causes the reader to fail with ClassCastException. This is because the Spring injection mechanism doesn't have a chance to convert the values as it would do for regular properties.

It would be also useful to have implementation of enum JobParameters.


No further details from BATCH-1581

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

You can use Spring EL to make objects of an explicit type, e.g. "#{new Integer('1')}", or "#{T(my.company.MyEnum).valueOf('FOO')}". In the light of that I am reluctant to add more complications to the JobParameters (mainly because of the persistence requirements).

@spring-projects-issues
Copy link
Collaborator Author

Tomasz Blachowicz commented

EL is great, but I'm not sure if it can be used with Spring 2.5 setup, that I deal with currently. BTW, how would Spring EL work with JobParameter? Is this something like "#{new Integer(#{jobParameters[intAsString]})}"?

I've implemented some changes to Spring Batch Core to provide support for Integer and Boolean types. IT seems that it works OK. For the persistence I use existing columns. In case the parameter is of type Integer the value is stored in LONG_VAL column and the Boolean value is stored in STRING_VALUE. What is your opinion on such approach?

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

Thanks for trying it out. I just don't think we should put any effort into supporting Spring 2.5 when those features are obsolete with the current version of the framework (3.0). With Spring 2.5 it should still work if you initialise your map values with inner bean definitions, e.g.

<entry key="foo"><bean class="java.lang.Integer"><constructor-arg value="#{jobParameters['foo']}"/></bean></entry>

It's not pretty, but it works and it's really a corner case.

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

Or even (slightly prettier):

<entry key="foo"><value type="java.lang.Integer">#{jobParameters['foo']}</value></entry> 

@spring-projects-issues
Copy link
Collaborator Author

Tomasz Blachowicz commented

Dave, thanks for the explanation. I have already used that approach with java.lang.Integer.valueOf as factory method.

@spring-projects-issues spring-projects-issues added status: declined Features that we don't intend to implement or Bug reports that are invalid or missing enough details type: enhancement in: core labels Dec 16, 2019
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* spring-projects#3960
* spring-projects#2122
* spring-projects#1035
* spring-projects#1983
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* spring-projects#3960
* spring-projects#2122
* spring-projects#1035
* spring-projects#1983
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* spring-projects#3960
* spring-projects#2122
* spring-projects#1035
* spring-projects#1983
fmbenhassine added a commit that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* #3960
* #2122
* #1035
* #1983
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: declined Features that we don't intend to implement or Bug reports that are invalid or missing enough details type: enhancement
Projects
None yet
Development

No branches or pull requests

1 participant