I have an entity mapped with "dynamic-update" and a version column.
Updating an unchanged detached entity results in an empty SQL update statement which leads to a SQLGrammarException.
UPDATE foo SET WHERE ID = 1 AND Version = 1
My update method I pass a detached unchanged entity to:
public static void update(final Session session, final Object entity) { if (session.contains(entity)) return; final Serializable identifier = HibernateUtils.getIdentifier(session, entity).getValue(); final Object sessionEntity = session.load(entity.getClass(), identifier); if (sessionEntity != null) session.evict(sessionEntity); session.update(entity); }
This is very annoying on the client if someone presses update button without having changed any form values.
|