|
|
|
@ -31,14 +31,14 @@ import java.util.List; |
|
|
|
@SqlDao |
|
|
|
public class AttributeKvInsertRepository extends AbstractVersionedInsertRepository<AttributeKvEntity> { |
|
|
|
|
|
|
|
private static final String BATCH_UPDATE = "UPDATE attribute_kv SET str_v = ?, long_v = ?, dbl_v = ?, bool_v = ?, json_v = cast(? AS json), last_update_ts = ?, version = nextval('attribute_kv_version_seq') " + |
|
|
|
private static final String BATCH_UPDATE = "UPDATE attribute_kv SET str_v = ?, long_v = ?, dbl_v = ?, bool_v = ?, json_v = cast(? AS json), last_update_ts = ?, version = version + 1 " + |
|
|
|
"WHERE entity_id = ? and attribute_type =? and attribute_key = ? RETURNING version;"; |
|
|
|
|
|
|
|
private static final String INSERT_OR_UPDATE = |
|
|
|
"INSERT INTO attribute_kv (entity_id, attribute_type, attribute_key, str_v, long_v, dbl_v, bool_v, json_v, last_update_ts, version) " + |
|
|
|
"VALUES(?, ?, ?, ?, ?, ?, ?, cast(? AS json), ?, nextval('attribute_kv_version_seq')) " + |
|
|
|
"INSERT INTO attribute_kv (entity_id, attribute_type, attribute_key, str_v, long_v, dbl_v, bool_v, json_v, last_update_ts) " + |
|
|
|
"VALUES(?, ?, ?, ?, ?, ?, ?, cast(? AS json), ?) " + |
|
|
|
"ON CONFLICT (entity_id, attribute_type, attribute_key) " + |
|
|
|
"DO UPDATE SET str_v = ?, long_v = ?, dbl_v = ?, bool_v = ?, json_v = cast(? AS json), last_update_ts = ?, version = nextval('attribute_kv_version_seq') RETURNING version;"; |
|
|
|
"DO UPDATE SET str_v = ?, long_v = ?, dbl_v = ?, bool_v = ?, json_v = cast(? AS json), last_update_ts = ?, version = attribute_kv.version + 1 RETURNING version;"; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void setOnBatchUpdateValues(PreparedStatement ps, int i, List<AttributeKvEntity> entities) throws SQLException { |
|
|
|
@ -121,4 +121,4 @@ public class AttributeKvInsertRepository extends AbstractVersionedInsertReposito |
|
|
|
protected String getInsertOrUpdateQuery() { |
|
|
|
return INSERT_OR_UPDATE; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|