mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
#467 - Delete bean with unloaded version property throws OptimisticLockException - API Change, return boolean
This commit is contained in:
1 parent
a2ee0bfdbe
commit
a578eda2b1
18 files changed
+150
-54
No files matched your search
@@ -46,9 +46,10 @@ public class DeleteHandler extends DmlHandler {
|
||||
* Execute the delete non-batch.
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws SQLException, OptimisticLockException {
|
||||
public int execute() throws SQLException, OptimisticLockException {
|
||||
int rowCount = dataBind.executeUpdate();
|
||||
checkRowCount(rowCount);
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,10 +35,10 @@ public final class DmlBeanPersister implements BeanPersister {
|
||||
/**
|
||||
* execute the bean delete request.
|
||||
*/
|
||||
public void delete(PersistRequestBean<?> request) {
|
||||
public int delete(PersistRequestBean<?> request) {
|
||||
|
||||
DeleteHandler delete = new DeleteHandler(request, deleteMeta);
|
||||
execute(request, delete);
|
||||
return execute(request, delete);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,15 +62,17 @@ public final class DmlBeanPersister implements BeanPersister {
|
||||
/**
|
||||
* execute request taking batching into account.
|
||||
*/
|
||||
private void execute(PersistRequestBean<?> request, PersistHandler handler) {
|
||||
private int execute(PersistRequestBean<?> request, PersistHandler handler) {
|
||||
|
||||
boolean batched = request.isBatched();
|
||||
try {
|
||||
handler.bind();
|
||||
if (batched) {
|
||||
handler.addBatch();
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
handler.execute();
|
||||
return handler.execute();
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
||||
* Execute now for non-batch execution.
|
||||
*/
|
||||
@Override
|
||||
public abstract void execute() throws SQLException;
|
||||
public abstract int execute() throws SQLException;
|
||||
|
||||
/**
|
||||
* Check the rowCount.
|
||||
|
||||
@@ -125,8 +125,8 @@ public class InsertHandler extends DmlHandler {
|
||||
* getGeneratedKeys if required.
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws SQLException, OptimisticLockException {
|
||||
int rc = dataBind.executeUpdate();
|
||||
public int execute() throws SQLException, OptimisticLockException {
|
||||
int rowCount = dataBind.executeUpdate();
|
||||
if (useGeneratedKeys) {
|
||||
// get the auto-increment value back and set into the bean
|
||||
getGeneratedKeys();
|
||||
@@ -136,8 +136,9 @@ public class InsertHandler extends DmlHandler {
|
||||
fetchGeneratedKeyUsingSelect();
|
||||
}
|
||||
|
||||
checkRowCount(rc);
|
||||
checkRowCount(rowCount);
|
||||
executeDerivedRelationships();
|
||||
return rowCount;
|
||||
}
|
||||
|
||||
protected void executeDerivedRelationships() {
|
||||
@@ -210,16 +211,14 @@ public class InsertHandler extends DmlHandler {
|
||||
rset.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
String msg = "Error closing rset for fetchGeneratedKeyUsingSelect?";
|
||||
logger.warn(msg, ex);
|
||||
logger.warn("Error closing ResultSet for fetchGeneratedKeyUsingSelect?", ex);
|
||||
}
|
||||
try {
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
String msg = "Error closing stmt for fetchGeneratedKeyUsingSelect?";
|
||||
logger.warn(msg, ex);
|
||||
logger.warn("Error closing Statement for fetchGeneratedKeyUsingSelect?", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface PersistHandler {
|
||||
/**
|
||||
* Execute now for non-batch execution.
|
||||
*/
|
||||
void execute() throws SQLException;
|
||||
int execute() throws SQLException;
|
||||
|
||||
/**
|
||||
* Close resources including underlying preparedStatement.
|
||||
|
||||
@@ -67,11 +67,13 @@ public class UpdateHandler extends DmlHandler {
|
||||
* Execute the update in non-batch.
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws SQLException, OptimisticLockException {
|
||||
public int execute() throws SQLException, OptimisticLockException {
|
||||
if (!emptySetClause) {
|
||||
int rowCount = dataBind.executeUpdate();
|
||||
checkRowCount(rowCount);
|
||||
return rowCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user