vendredi 5 juin 2015

How to update multiple entities with different random values via JPQL

i need some help in formulating the correct JPQL query in Spring Data with JPA.

The usecase is: Update a certain attribute of a bunch of Entities with a random value, and for every updated entity the random value must be different.

I tried this:

@Query("update Entity e set e.randomValue = UUID.randomUUID().toString())
void updateRandomValue()

This is pure JPQL, but the result is, that every Entity has now the same random value.

I could make it work with a native query query, but i really would like to have pure JPQL to be DB independent.

Any clue? Thanks!




Aucun commentaire:

Enregistrer un commentaire