In a project, I in Hibernate and Spring jdbctemplate are mixed. I added an upbeat lock. Hibernate works fine with versions, but now I need to convert all this jdbctemplate code to use version control.
Is there something like LockingJdbcTemplate (e.g. SimpleJdbcTemplate)? I thought I could implement a general update method
update(String tableName, String columnsSql, String whereSql, Long version, Object... params)
Where could I:
- append version = version + 1 to columnSql
- add version =? to whereSql
- add a version number to correct the place in the parameters (a separate parameter forces this value to be transmitted)
- Make sure that exactly 1 element is updated and otherwise throw a StaleObjectStateException.
Is there any library that will wrap jdbctemplate and do something similar for me? Do not want to invent something that exists ... :)
Priit source
share