[jOOQ/jOOQ#15115] Improve error message when unversioned, row based
optimistic locking doesn't work with DAOs and POJOs
This commit is contained in:
parent
1b1808558e
commit
9b969d41cf
@ -40,8 +40,17 @@ package org.jooq.exception;
|
||||
import org.jooq.UpdatableRecord;
|
||||
|
||||
/**
|
||||
* An error occurred while storing a record whose underlying data had already
|
||||
* been changed
|
||||
* An error occurred while storing a record with optimistic locking active,
|
||||
* whose underlying data had already been changed.
|
||||
* <p>
|
||||
* This exception may be thrown if:
|
||||
* <ul>
|
||||
* <li>The record has been changed.</li>
|
||||
* <li>The record has been removed.</li>
|
||||
* <li>It isn't possible to detect whether the record has been changed (e.g.
|
||||
* because {@link UpdatableRecord#update()} is called on a record that hasn't
|
||||
* been previously fetched from the database).</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see UpdatableRecord#store()
|
||||
* @author Lukas Eder
|
||||
|
||||
@ -504,7 +504,10 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
Object thatObject = record.original(field);
|
||||
|
||||
if (!StringUtils.equals(thisObject, thatObject))
|
||||
throw new DataChangedException("Database record has been changed");
|
||||
if (thisObject == null && !fetched)
|
||||
throw new DataChangedException("Cannot detect whether unversioned record has been changed. Either make sure the record is fetched from the database, or use a version or timestamp column to version the record.");
|
||||
else
|
||||
throw new DataChangedException("Database record has been changed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user