diff --git a/src/main/java/net/ucanaccess/commands/UpdateCommand.java b/src/main/java/net/ucanaccess/commands/UpdateCommand.java index 8cef18b1..508a7b32 100644 --- a/src/main/java/net/ucanaccess/commands/UpdateCommand.java +++ b/src/main/java/net/ucanaccess/commands/UpdateCommand.java @@ -133,15 +133,17 @@ private void updateComplex(Cursor cur) throws IOException { } else if (modifiedRow[j] instanceof Version[]) { Version[] vs = (Version[]) modifiedRow[j]; - Version v = vs[0]; - List oldV = rowFk.getVersions(); - String vn = v.getValue(); - String vo = !oldV.isEmpty() ? oldV.get(0).getValue() : null; - LocalDateTime upTime = isRollbacking ? LocalDateTime.now() : v.getModifiedDate(); - - if (vn != null && vo == null || vo != null && vn == null - || vo != null && vn != null && !vo.equals(vn)) { - rowFk.addVersion(vn, upTime); + if (vs.length > 0) { + Version v = vs[0]; + List oldV = rowFk.getVersions(); + String vn = v.getValue(); + String vo = !oldV.isEmpty() ? oldV.get(0).getValue() : null; + LocalDateTime upTime = isRollbacking ? LocalDateTime.now() : v.getModifiedDate(); + + if (vn != null && vo == null || vo != null && vn == null + || vo != null && vn != null && !vo.equals(vn)) { + rowFk.addVersion(vn, upTime); + } } }