我有
Foo
作为
Bar
作为它的财产
OneToOne
关系。
@Entity
@Table(name="FOO")
public class Foo {
@Id
@Column(name="FOO_ID", nullable=false)
private UUID fooId;
@OneToOne
private Bar bar;
}
两个实体在数据库中都有自己的表。桌子
其主键为
bar_id
和外键
foo_id
. 我试图从
酒吧
使用自定义存储库的特定条件表从spring data jpa扩展了jpa repository。
this.barRepository.delete(foo.getBarId());
但是我遇到了
java.lang.illegalargumentexception attempt to create merge event with null entity
. 我读了一篇关于它的文章
null
foo.getBarId()
通过调试不为空。
我不知道出了什么问题以及如何纠正。
[更新]
BarRepository
具有错误的实体类型。
public interface BarRepository extends JpaRepository<Foo, UUID>
public interface BarRepository extends JpaRepository<Bar, UUID>