java - JPA+JSONB 集合上的休眠方案验证失败
问题描述
我正在尝试将 JSONB 列映射到 Set(非内置目标),但是当方案验证器在开始时运行时,它会失败,因为我没有连接表(此模型不需要)。
@Entity
@Table(name = "my_class")
public classs Class extends BaseEntity<Long> {
@ElementCollection(targetClass = ClassSchedule.class) // This is to correctly map the generated meta-model
@Column(name = "schedules", nullable = false, columnDefinition = "JSONB")
@Convert(attributeName = "schedules", converter = ClassSchedule.ClassSchedulesConverter.class) //Class's mapper
private Set<ClassSchedule> schedules;
}
由于添加了@ElementCollection
注释,当我运行此代码时,hibernate 仍希望此表class_schedule
存在。我知道我可以从配置中禁用方案验证,但我宁愿避免这样做。
关于如何正确映射该字段的任何想法?
编辑:
虽然我可以使用@Type
hybernate 的类型(我最初是这样做的),但它会导致元模型生成/映射出现问题:
expected type : org.hibernate.metamodel.model.domain.internal.SingularAttributeImpl; encountered type : javax.persistence.metamodel.SetAttribute
这就是为什么我决定添加@ElementCollection
现在提示当前问题的原因,因为它需要一个连接表。
解决方案
推荐阅读
- python - 有没有更好的方法来获取字典列表中的字典值?
- flutter - 颤振的相机插件没有像预期的那样工作,并不断给出很大的错误消息
- flutter - Flutter Firebase 事务
- unity3d - Unity Editor 脚本、ApplyModifiedParametesr 和保存场景。有些东西不工作
- python - 如何用python绕过响应503
- git - 运行“patch -p1 < patch-file”时出现“git binary diffs are not supported”错误
- javascript - 为什么检查的伪类在 css 中不起作用?
- java - 将霍夫曼编码的字符串写入Java文件时如何处理奇数字节?
- python - 测试列表中所有可能性的程序
- javascript - 如何在不知道调用者函数的情况下拦截 javascript 中的 api 调用?