use of org.dbflute.exception.OptimisticLockColumnValueNullException in project dbflute-core by dbflute.
the class BehaviorExceptionThrower method throwVersionNoValueNullException.
public void throwVersionNoValueNullException(Entity entity) {
final ExceptionMessageBuilder br = createExceptionMessageBuilder();
br.addNotice("Not found the value of 'version no' on the entity!");
br.addItem("Advice");
br.addElement("Please confirm the existence of the value of 'version no' on the entity.");
br.addElement("You called the method in which the check for optimistic lock is indispensable.");
br.addElement("So 'version no' is required on the entity.");
br.addElement("In addition, please confirm the necessity of optimistic lock.");
br.addElement("For example:");
br.addElement(" (x):");
br.addElement(" Member member = new Member();");
br.addElement(" member.setMemberId(3);");
br.addElement(" member.setMemberName(\"Pixy\");");
br.addElement(" memberBhv.update(member);");
br.addElement(" (o): (Optimistic Lock)");
br.addElement(" Member member = new Member();");
br.addElement(" member.setMemberId(3);");
br.addElement(" member.setMemberName(\"Pixy\");");
br.addElement(" member.setVersionNo(...); // *Point");
br.addElement(" memberBhv.update(member);");
br.addElement(" (o): (Nonstrict)");
br.addElement(" Member member = new Member();");
br.addElement(" member.setMemberId(3);");
br.addElement(" member.setMemberName(\"Pixy\");");
br.addElement(" memberBhv.updateNonstrict(member); // *Point");
setupEntityElement(br, entity);
final String msg = br.buildExceptionMessage();
throw new OptimisticLockColumnValueNullException(msg);
}
use of org.dbflute.exception.OptimisticLockColumnValueNullException in project dbflute-core by dbflute.
the class AbstractBehaviorWritable method helpInsertOrUpdateInternally.
protected <RESULT extends ENTITY> void helpInsertOrUpdateInternally(RESULT entity, InsertOption<CB> insOption, UpdateOption<CB> updOption) {
assertEntityNotNull(entity);
if (helpDetermineInsertOrUpdateDirectInsert(entity)) {
doCreate(entity, insOption);
return;
}
RuntimeException updateException = null;
try {
doModify(entity, updOption);
} catch (EntityAlreadyUpdatedException e) {
// already updated (or means not found)
updateException = e;
} catch (EntityAlreadyDeletedException e) {
// means not found
updateException = e;
} catch (OptimisticLockColumnValueNullException e) {
// means insert?
updateException = e;
}
if (updateException == null) {
return;
}
final CB cb = newConditionBean();
final Set<String> uniqueDrivenProperties = entity.myuniqueDrivenProperties();
if (uniqueDrivenProperties != null && !uniqueDrivenProperties.isEmpty()) {
for (String prop : uniqueDrivenProperties) {
final DBMeta dbmeta = entity.asDBMeta();
final ColumnInfo columnInfo = dbmeta.findColumnInfo(prop);
// already checked in update process
final Object value = columnInfo.read(entity);
cb.localCQ().invokeQueryEqual(columnInfo.getColumnDbName(), value);
}
} else {
cb.acceptPrimaryKeyMap(asDBMeta().extractPrimaryKeyMap(entity));
}
if (readCount(cb) == 0) {
// anyway if not found, insert
doCreate(entity, insOption);
} else {
throw updateException;
}
}
use of org.dbflute.exception.OptimisticLockColumnValueNullException in project dbflute-core by dbflute.
the class BehaviorExceptionThrower method throwUpdateDateValueNullException.
public void throwUpdateDateValueNullException(Entity entity) {
final ExceptionMessageBuilder br = createExceptionMessageBuilder();
br.addNotice("Not found the value of 'update date' on the entity!");
br.addItem("Advice");
br.addElement("Please confirm the existence of the value of 'update date' on the entity.");
br.addElement("You called the method in which the check for optimistic lock is indispensable.");
br.addElement("So 'update date' is required on the entity.");
br.addElement("In addition, please confirm the necessity of optimistic lock.");
br.addElement("For example:");
br.addElement(" (x):");
br.addElement(" Member member = new Member();");
br.addElement(" member.setMemberId(3);");
br.addElement(" member.setMemberName(\"Pixy\");");
br.addElement(" memberBhv.update(member);");
br.addElement(" (o): (Optimistic Lock)");
br.addElement(" Member member = new Member();");
br.addElement(" member.setMemberId(3);");
br.addElement(" member.setMemberName(\"Pixy\");");
br.addElement(" member.setUpdateDatetime(updateDatetime); // *Point");
br.addElement(" memberBhv.update(member);");
br.addElement(" (o): (Nonstrict)");
br.addElement(" Member member = new Member();");
br.addElement(" member.setMemberId(3);");
br.addElement(" member.setMemberName(\"Pixy\");");
br.addElement(" memberBhv.updateNonstrict(member); // *Point");
setupEntityElement(br, entity);
final String msg = br.buildExceptionMessage();
throw new OptimisticLockColumnValueNullException(msg);
}
Aggregations