派生查询与JPA和Spring Data的无效@OnetoOne关系
我有一个entity1和entity2
@Entity
class Entity1 {
@Id
@Column(name = "entity_id")
private Long entityId;
@OneToOne(orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "entity_id")
private Entity2 entity2;
...
}
我如何得出所有具有null Entity2的entity1对象? Intellij Idea告诉我我可以使用这样的smth:
List<Entity1> findAllByEntity2IsNull()
但是那不起作用,返回空列表总是
我尝试使用相对的变体:
List<Entity1> findAllByEntity2IsNotNull()
但是该变体返回所有具有null的条目,而不是null值
I have a Entity1 and Entity2
@Entity
class Entity1 {
@Id
@Column(name = "entity_id")
private Long entityId;
@OneToOne(orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "entity_id")
private Entity2 entity2;
...
}
How can I derived query all Entity1 objects that has a null entity2?
IntelliJ Idea tell that i can use smth like that:
List<Entity1> findAllByEntity2IsNull()
But that doesn't work and return empty list always
I tried to use an opposite variant:
List<Entity1> findAllByEntity2IsNotNull()
But that variant return all entries that have null and not null values
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜,找到 all byentity2isnull会使弹簧数据混淆,因此请尝试使用名称的方法
I guess, findAllByEntity2IsNull confuses Spring Data, so try using method with name