java - 共享类不能引用隔离类
问题描述
我正在添加一个映射到现有实体的全新实体:
@Entity
@IdClass(NewEntityPK.class)
public class NewEntity implements Serializable {
@Id
@Column(name="USER_ID", nullable = false, length = 256)
private String userId;
@Id
@ManyToOne
@JoinColumn(name = "EXISTING_ENTITY_ID", referencedColumnName = "EXISTING_ENTITY_ID", nullable = false)
private ExistingEntity existingEntity;
}
@Entity
@Cacheable(true)
public class ExistingEntity implements Serializable {
}
部署后,我得到:
异常 [EclipseLink-195] (Eclipse Persistence Services - 2.1.3.v20110304-r9073):org.eclipse.persistence.exceptions.DescriptorException
异常描述:共享类 com.example.model.NewEntity 不得引用隔离类 com。 example.model.ExistingEntity。
映射:org.eclipse.persistence.mappings.ManyToOneMapping[existingEntity]
描述符:RelationalDescriptor(com.example.model.NewEntity --> [DatabaseTable(NEW_ENTITY)])
我知道这是因为ExistingEntity
被注释为不可缓存。不幸的是,我不能只启用缓存,因为它在实体图周围级联,所以我也被迫禁用缓存NewEntity
。
是否有替代方案允许在NewEntity
不接触其他实体的情况下保持缓存?如果这很重要,我很可能只需要从 开始获取一级链接关系NewEntity
。
解决方案
推荐阅读
- viber - 通过 REST API 在 for 循环中发送 Viber 机器人消息多次触发
- java - 在 java 中使用 GZIPOutputStream 或 ZIPOutputStream 时是否可以排除文件和/或目录?
- ios - 内容左对齐 - SwiftUI iOS 14 Widget
- java - 文件中的数字
- parallel-processing - 在 2020 年,在一台计算机上的多个 GPU 上使用 Pytorch 训练模型的最佳方式是什么?
- python - 为什么要创建一个二进制列来指示具有缺失值的记录
- python - 在 python 中打印列表有不同的方法吗?
- neo4j - 计算最短路径neo4j后的节点数
- node.js - 有没有办法查看有多少用户加入了我的不和谐机器人游戏?
- pandas - xarray,用多维坐标索引