I have a Spring Batch job that needs to write all items to a DB in one chunk. I want this behavior because 

1. I need to do some validation involving comparisons among the read items prior to writing.
2. If any validation fails, I need to make sure that no items are persisted or all items are persisted.
3. It's a small amount of data < 60kb.

The item is a `Car` and it has a `Model` property. The problem that I'm having is that part of the item processing checks to see if the `Model` already exists in the database. If it does, it retrieves the model from the DB (including auto generated id) and therefore does not create another DB entry.

Now, that works fine if the `Model` was already persisted in a previous job run. However, it fails when the same `Model` shows up for two different `Car`s in the same job run and the `Model` was not persisted previously. In that case, two database rows get created for the same `Model`.

I'm using JPA with `Model` having an id property annotated with `@Id` and `@GeneratedValue(strategy = GenerationType.IDENTITY)`. How can I ensure prior to writing that the same `Model` is not written to the database more than once?