修复DataSource中json字段不为Serializable时会异常的bug

This commit is contained in:
Redkale
2019-06-13 22:23:30 +08:00
parent 427ff717d4
commit ef3663aa36
2 changed files with 4 additions and 4 deletions

View File

@@ -177,7 +177,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
protected <T> int batchStatementParameters(Connection conn, PreparedStatement prestmt, EntityInfo<T> info, Attribute<T, Serializable>[] attrs, T entity) throws SQLException { protected <T> int batchStatementParameters(Connection conn, PreparedStatement prestmt, EntityInfo<T> info, Attribute<T, Serializable>[] attrs, T entity) throws SQLException {
int i = 0; int i = 0;
for (Attribute<T, Serializable> attr : attrs) { for (Attribute<T, Serializable> attr : attrs) {
Serializable val = info.getSQLValue(attr, entity); Object val = info.getSQLValue(attr, entity);
if (val instanceof byte[]) { if (val instanceof byte[]) {
Blob blob = conn.createBlob(); Blob blob = conn.createBlob();
blob.setBytes(1, (byte[]) val); blob.setBytes(1, (byte[]) val);

View File

@@ -902,10 +902,10 @@ public final class EntityInfo<T> {
* *
* @return Object * @return Object
*/ */
public Serializable getSQLValue(Attribute<T, Serializable> attr, T entity) { public <F> Object getSQLValue(Attribute<T, F> attr, T entity) {
Serializable val = attr.get(entity); Object val = attr.get(entity);
CryptHandler cryptHandler = attr.attach(); CryptHandler cryptHandler = attr.attach();
if (cryptHandler != null) val = (Serializable) cryptHandler.encrypt(val); if (cryptHandler != null) val = cryptHandler.encrypt(val);
return val; return val;
} }