该异常表示未保存的临时实例
org.hibernate.TransientPropertyValueException:
object references an unsaved transient instance - save the transient instance before flushing
这个错误是由于JPA中的枚举属性手动初始化导致的,实体中存在对其他实体的引用,但是该引用的实体并没有存在于已有的数据库中和hibernate缓存中。
项目中手动初始化枚举:
@Enumerated(value = EnumType.STRING)
private FolderType folderType = FolderType.NORMAL;
改为:
@Column(length = 32, columnDefinition = "varchar(32) default 'NORMAL'")
@Enumerated(value = EnumType.STRING)
private FolderType folderType;