-
May 20th, 2008, 02:49 AM
#1
Alter the fieldset value
Hi,
I want to read from a file and checks some conditions on record and do some changes on few fields then after write to database.
Do to this, first I thought read record and do the verification of conditions and alteration of field values on FieldSet then write to database. But the implemetation class for FieldSet is provided by frame work. So I cant do that.
Please guide me to solve this issue.
Thanks in advance,
Shahul
-
May 20th, 2008, 04:01 AM
#2
There is a related issue: http://jira.springframework.org/browse/BATCH-394
Currently you'll need to create new modified FieldSet instance rather than change values in the original instance.
-
May 20th, 2008, 07:15 AM
#3
Couldn't you change some of the fields when you put them into a domain object?
-
May 20th, 2008, 08:33 AM
#4
I am not using any specific VO classes, instead we are using map.
I have two options.
One is, alter the values just after creating tokens of fields but before creating fieldset. So we can instantiate fieldset with updated values.
Second one is, extend our DefaultFieldSet class with options to updated the tokens. So we can alter the values just after tokenizing but before the fieldsetmapper.
Please guide me to take a solution.
~Shahul
-
May 20th, 2008, 09:30 AM
#5
I'm still confused, can't you alter the values when moving them from the fieldset to the map?
-
May 20th, 2008, 09:59 AM
#6
Yes Lucas, We can alter the values in map. But I want to segregate that functions with creation of map. Because the alteration is little bit trickier. More of that, according to some values, i need to skip entire record from writing to database. Thats why I am thinking for a better solution.
-
May 20th, 2008, 10:07 AM
#7
The skip part is easy, just throw an exception, and configure it as skippable. To be honest, I think modifying the values in the map is still your best option. A FieldSet is immutable for good reason, it is purely a transfer mechanism. If you absolutely don't want to do it in the map, put another abstraction between the fieldset and the map, but I would still leave the FieldSet alone.
-
May 20th, 2008, 10:30 AM
#8
Thanks Lucas for your valuable suggestion. I will put a abstraction between fieldset and map such that create a new instance of fieldset using updated values in original instance of fieldset.
I didnt understand to skip record using exception, please guide me.
-
May 20th, 2008, 10:37 AM
#9
Lucas,
I think above method also change the fieldset indirectly by creating new fieldset using updated values. Is it ok? I took the suggestion of Robert. Please guide me.
-
May 20th, 2008, 11:08 AM
#10
Here's the section in the documentation about configuring skip:
http://static.springframework.org/sp...n.html#d0e3747
You could use another FieldSet as your abstraction if you like, although it might be a bit overkill depending upon how many fields you need to alter.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules