DATAJDBC-119 - Fix broken tests with other databases.

Fixed sql scripts for the various databases.

Postgres doesn't handle BigInts properly when just past to setObject. It needs special SqlType information.

Postgres can only handle BigInts up to Long.MAX_VALUE.

MySql stores dates only with seconds precision.
This commit is contained in:
Jens Schauder
2017-08-08 10:04:16 +02:00
committed by Greg Turnquist
parent b8fe3c67c0
commit 36daba0f42
9 changed files with 58 additions and 18 deletions

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.jdbc.core;
import java.math.BigInteger;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -49,6 +51,7 @@ import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty;
import org.springframework.data.mapping.PropertyHandler;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.jdbc.core.SqlParameterValue;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.jdbc.support.GeneratedKeyHolder;
@@ -279,7 +282,11 @@ public class JdbcEntityTemplate implements JdbcEntityOperations {
Object value = persistentEntity.getPropertyAccessor(instance).getProperty(property);
Object convertedValue = convert(value, property.getColumnType());
parameters.put(property.getColumnName(), convertedValue);
if (convertedValue instanceof BigInteger) {
parameters.put(property.getColumnName(), new SqlParameterValue(Types.BIGINT, convertedValue));
} else {
parameters.put(property.getColumnName(), convertedValue);
}
}
});