引入依赖
com.vladmihalcea
hibernate-types-52
2.4.3
定义实体类
@Data
@Entity
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class ExpressOrder{
/**主键自增 */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**商品相关信息 */
@Type(type = "json")
@Column(columnDefinition = "json" )
private List cargoModelList;
/**增值服务信息 */
@Type(type = "json")
@Column(columnDefinition = "json" )
private List addedServiceModelList;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CargoModel implements Serializable {
private String name;// 货物名称
private String count;// 货物数量
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AddedServiceModel implements Serializable {
private String name;//增值服务名,如COD等。
private String value;
private String value1;
}
说明:addedServiceModelList 和cargoModelList 分别表示 表中字段added_service_model_list 和 cargo_model_list,其类型均为json