private ProcessEntry get(DSLContext tx, PartialProcessKey key, Set<ProcessDataInclude> includes) { SelectQuery<Record> query = buildSelect(tx, includes); query.addConditions(PROCESS_QUEUE.INSTANCE_ID.eq(key.getInstanceId())); return query.fetchOne(this::toEntry); }
/** * Perform an additional SELECT .. FOR UPDATE to check if the underlying * database record has been changed compared to this record. */ private final void checkIfChanged(TableField<R, ?>[] keys) { SelectQuery<R> select = create().selectQuery(getTable()); Utils.addConditions(select, this, keys); // [#1547] MS Access and SQLite doesn't support FOR UPDATE. CUBRID and SQL Server // can simulate it, though! if (!asList(SQLITE).contains(create().configuration().dialect().family())) { select.setForUpdate(true); } R record = select.fetchOne(); if (record == null) { throw new DataChangedException("Database record no longer exists"); } for (Field<?> field : fields.fields.fields) { Value<?> thisValue = getValue0(field); Value<?> thatValue = ((AbstractRecord) record).getValue0(field); Object thisObject = thisValue.getOriginal(); Object thatObject = thatValue.getOriginal(); if (!StringUtils.equals(thisObject, thatObject)) { throw new DataChangedException("Database record has been changed"); } } }
/** * Perform an additional SELECT .. FOR UPDATE to check if the underlying * database record has been changed compared to this record. */ private final void checkIfChanged(TableField<R, ?>[] keys) { SelectQuery<R> select = create().selectQuery(getTable()); Tools.addConditions(select, this, keys); // [#1547] MS Access and SQLite doesn't support FOR UPDATE. CUBRID and SQL Server // can emulate it, though! if (!NO_SUPPORT_FOR_UPDATE.contains(create().configuration().dialect().family())) select.setForUpdate(true); R record = select.fetchOne(); if (record == null) throw new DataChangedException("Database record no longer exists"); for (Field<?> field : fields.fields.fields) { Object thisObject = original(field); Object thatObject = record.original(field); if (!StringUtils.equals(thisObject, thatObject)) throw new DataChangedException("Database record has been changed"); } }