[#2265] Removed delete again, for now. This seems to be very complex to
get right.
This commit is contained in:
parent
dce7021ca6
commit
a43082d1aa
@ -1042,8 +1042,6 @@ public interface Record extends Attachable, Comparable<Record> {
|
||||
// Methods related to the underlying ResultSet (if applicable)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
int delete() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Refresh this record from the database.
|
||||
* <p>
|
||||
@ -1068,11 +1066,12 @@ public interface Record extends Attachable, Comparable<Record> {
|
||||
*
|
||||
* @throws DataAccessException This exception is thrown if
|
||||
* <ul>
|
||||
* <li>something went wrong executing the query</li> <li>the
|
||||
* {@link #resultSet()} is not available, or is in
|
||||
* <li>the underlying {@link #resultSet()} is in
|
||||
* {@link ResultSet#TYPE_FORWARD_ONLY} mode, such that
|
||||
* refreshing is not possible.</li><li>the record does not exist
|
||||
* anymore in the database</li>
|
||||
* refreshing is not possible.</li> <li>something went wrong
|
||||
* executing the refresh <code>SELECT</code> statement, if this
|
||||
* is an {@link UpdatableRecord}.</li> <li>the record does not
|
||||
* exist anymore in the database</li>
|
||||
* </ul>
|
||||
* @see UpdatableRecord#refresh()
|
||||
* @see ResultQuery#keepResultSet(KeepResultSetMode)
|
||||
@ -1103,11 +1102,12 @@ public interface Record extends Attachable, Comparable<Record> {
|
||||
*
|
||||
* @throws DataAccessException This exception is thrown if
|
||||
* <ul>
|
||||
* <li>something went wrong executing the query</li> <li>the
|
||||
* {@link #resultSet()} is not available, or is in
|
||||
* <li>the underlying {@link #resultSet()} is in
|
||||
* {@link ResultSet#TYPE_FORWARD_ONLY} mode, such that
|
||||
* refreshing is not possible.</li><li>the record does not exist
|
||||
* anymore in the database</li>
|
||||
* refreshing is not possible.</li> <li>something went wrong
|
||||
* executing the refresh <code>SELECT</code> statement, if this
|
||||
* is an {@link UpdatableRecord}.</li> <li>the record does not
|
||||
* exist anymore in the database</li>
|
||||
* </ul>
|
||||
* @see UpdatableRecord#refresh()
|
||||
* @see ResultQuery#keepResultSet(KeepResultSetMode)
|
||||
|
||||
@ -298,7 +298,6 @@ public interface UpdatableRecord<R extends UpdatableRecord<R>> extends TableReco
|
||||
* @throws DataChangedException If optimistic locking is enabled and the
|
||||
* record has already been changed/deleted in the database
|
||||
*/
|
||||
@Override
|
||||
int delete() throws DataAccessException, DataChangedException;
|
||||
|
||||
/**
|
||||
|
||||
@ -694,28 +694,6 @@ abstract class AbstractRecord extends AbstractStore implements Record {
|
||||
// XXX: Methods related to the underlying ResultSet (if applicable)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* Subclasses may override this
|
||||
*/
|
||||
@Override
|
||||
public int delete() {
|
||||
checkRsAvailable("Cannot delete record. No ResultSet available");
|
||||
|
||||
try {
|
||||
|
||||
// [#2265] TODO: This code is prototypical.
|
||||
rs.absolute(rsIndex - 1);
|
||||
rs.deleteRow();
|
||||
|
||||
return 1;
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw translate("Cannot delete record", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void refresh() {
|
||||
refresh(fields.fields.fields);
|
||||
|
||||
@ -302,40 +302,35 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
|
||||
@Override
|
||||
public final int delete() {
|
||||
if (rs != null) {
|
||||
return super.delete();
|
||||
}
|
||||
else {
|
||||
TableField<R, ?>[] keys = getPrimaryKey().getFieldsArray();
|
||||
TableField<R, ?>[] keys = getPrimaryKey().getFieldsArray();
|
||||
|
||||
try {
|
||||
DeleteQuery<R> delete1 = create().deleteQuery(getTable());
|
||||
Utils.addConditions(delete1, this, keys);
|
||||
try {
|
||||
DeleteQuery<R> delete1 = create().deleteQuery(getTable());
|
||||
Utils.addConditions(delete1, this, keys);
|
||||
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
|
||||
// [#1596] Add additional conditions for version and/or timestamp columns
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
addConditionForVersionAndTimestamp(delete1);
|
||||
}
|
||||
|
||||
// [#1547] Try fetching the Record again first, and compare this
|
||||
// Record's original values with the ones in the database
|
||||
else {
|
||||
checkIfChanged(keys);
|
||||
}
|
||||
// [#1596] Add additional conditions for version and/or timestamp columns
|
||||
if (isTimestampOrVersionAvailable()) {
|
||||
addConditionForVersionAndTimestamp(delete1);
|
||||
}
|
||||
|
||||
int result = delete1.execute();
|
||||
checkIfChanged(result, null, null);
|
||||
return result;
|
||||
// [#1547] Try fetching the Record again first, and compare this
|
||||
// Record's original values with the ones in the database
|
||||
else {
|
||||
checkIfChanged(keys);
|
||||
}
|
||||
}
|
||||
|
||||
// [#673] If store() is called after delete(), a new INSERT should
|
||||
// be executed and the record should be recreated
|
||||
finally {
|
||||
changed(true);
|
||||
}
|
||||
int result = delete1.execute();
|
||||
checkIfChanged(result, null, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
// [#673] If store() is called after delete(), a new INSERT should
|
||||
// be executed and the record should be recreated
|
||||
finally {
|
||||
changed(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user