mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Misc platform fixes (#1157)
* Oracle does not return row count - so we probably cannot detect Optimistic locking * DB2 wants a varchar null value (other platfroms are happy with this, too) * FIX Test for DB2 platform
This commit is contained in:
committed by
Rob Bygrave
parent
64bf6d6a35
commit
1651d5e119
@@ -31,6 +31,7 @@ import io.ebeanservice.docstore.api.DocStoreUpdates;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -784,8 +785,12 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
@Override
|
||||
public final void checkRowCount(int rowCount) {
|
||||
if (ConcurrencyMode.VERSION == concurrencyMode && rowCount != 1) {
|
||||
String m = Message.msg("persist.conc2", String.valueOf(rowCount));
|
||||
throw new OptimisticLockException(m, null, bean);
|
||||
// fix for oracle.
|
||||
// see: https://stackoverflow.com/questions/19022175/executebatch-method-return-array-of-value-2-in-java
|
||||
if (rowCount != Statement.SUCCESS_NO_INFO) {
|
||||
String m = Message.msg("persist.conc2", String.valueOf(rowCount));
|
||||
throw new OptimisticLockException(m, null, bean);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case DELETE:
|
||||
|
||||
@@ -184,7 +184,7 @@ public class ScalarTypeJsonObjectMapper {
|
||||
bind.setObject(PostgresHelper.asObject(pgType, rawJson));
|
||||
} else {
|
||||
if (value == null) {
|
||||
bind.setNull(Types.LONGNVARCHAR); // use longvarchar, otherwise SqlServer will fail with 'Invalid JDBC data type 5.001.'
|
||||
bind.setNull(Types.VARCHAR); // use varchar, otherwise SqlServer/db2 will fail with 'Invalid JDBC data type 5.001.'
|
||||
} else {
|
||||
try {
|
||||
String json = objectMapper.writeValueAsString(value);
|
||||
|
||||
Reference in New Issue
Block a user