java - 引起:java.lang.IllegalStateException:同一实体的多个表示
问题描述
我的数据库包含应用程序,每个应用程序都有功能。每个应用程序必须至少具有一项功能,并且每个功能都可以与多个应用程序相关。
应用程序的主要类别:
@Entity
@Table(name = ("apps"))
public class AppEntity implements Serializable {
@Id
@Column(name = ("app_id"), nullable = false)
private String appId;
@Column(name = ("app_name"), nullable = false)
private String packageName;
@OneToMany(mappedBy = "appEntity", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<AppFeatureEntity> appFeatures = new ArrayList<>();
特征类:
@Entity
@Table(name = ("app_features"))
public class AppFeaturesEntity implements Serializable {
@EmbeddedId
protected AppFeaturesEntityKey keys;
@ManyToOne(fetch=FetchType.LAZY, optional = false)
@JoinColumn(name = ("app_id"), insertable = false, updatable = false)
@JsonIgnore
private AppEntity appEntity;
PK类:
@Embeddable
public class AppFeaturesEntityKey implements Serializable {
@Column(name = ("feature_id"), nullable = false)
private String featureId;
@Column(name = ("app_id"), nullable = false)
private String appId;
我正在使用 ModelMapper 根据更新的实体更新旧实体,当我尝试调用时JpaRepository.saveAll(List<AppEntity>)
出现错误:
Multiple representations of the same entity [....AppFeaturesEntity#...AppFeaturesEntityKey@32d2bdd] are being merged
解决方案
推荐阅读
- javascript - 如何在 Django 上使用 python-highcharts 显示多个图表?
- sql - 获取每条记录在固定时间窗口中列的分区总和
- mysql - MySql 更新查询以插入 JSON 值
- javascript - fs.createReadStream 没有找到文件
- c# - 错误 powershell c# visual studio
- javascript - 如何在 D3 树形图中显示多个节点父节点?
- php - 如何在浏览器中获取 php-rdkafka 消息我将在命令行中尝试给出输出但不在浏览器中
- python - 在与 c 扩展交互时,IPython 的行为与 CPython 不同
- java - 扫描仪 Java 的简单注册验证表
- regex - rubular中的多行java异常正则表达式