mysql 存json,可行,
建议存储标签格式为jsonArray,理论上讲json格式都是可以的
最终实现为流过滤,代码实现举例
create table ep_test_json
(
id int auto_increment
primary key,
extra json null
);
INSERT INTO epower_atreus.ep_test_json (id, extra) VALUES (1, ‘[1, 2, 3, 4, 5, 6, 7]‘);
INSERT INTO epower_atreus.ep_test_json (id, extra) VALUES (3, ‘[1, 2, 3, 4, 5, 6]‘);
INSERT INTO epower_atreus.ep_test_json (id, extra) VALUES (5, ‘[1, 2, 3, 4, 5]‘);
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "epower_atreus.ep_test_json", autoResultMap = true)
public class EpTestJson implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@TableField(typeHandler = FastjsonTypeHandler.class)
private List<Integer> extra;
}
final List<EpTestJson> list = jsonService.list().stream()
.filter(json -> json.getExtra().stream().anyMatch(i -> i == 7))
.collect(Collectors.toList());
关联表,可行,
位移打标,可行,
原文:https://www.cnblogs.com/woooodlin/p/15184358.html