mysql
一、引入依赖
<!--JPA对数据库中JSON类型数据的支持-->
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-52</artifactId>
<version>2.12.1</version>
</dependency>
二、实体类
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@DynamicInsert
@DynamicUpdate
@Table(name = "test_predict")
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class TestPredict {
@Id
@Column(name="testId")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer testId;
private Integer stationId ;
private String projectId ;
private String stationName ;
private String longitude ;
private String latitude ;
private String relaMan ;
private String dataSource ;
private String dataType ;
private String taskStatus ;
private Date lastSendDate ;
private Boolean delFlag;
@Type(type = "json")
@Column(name = "userIds",columnDefinition = "json")
private List<WxUserDTO> userIds;
}
postresql
@Type(type = "json")
@Column(name = "instance_types", columnDefinition = "json")
private List<AliInstanceType> instanceTypes;