jparepository custom @query生成不需要的十字架加入
帐户实体代码:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
@NotFound(action = NotFoundAction.IGNORE)
private User user;
用户实体代码:
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Account> account = new ArrayList<>();
存储库自定义方法查询注释
@Query(value = "FROM Account a WHERE (:userId IS NULL Or a.user.id = :userId))
它生成此查询:
from account account0_ cross join user user1_ where account0_.user_id=user1_.id and (? is null or user1_.id=?)
在我将 springboot 从 2.1.4.release 更新到 2.6.5 之前工作正常,
预计如下:
from account account0_ WHERE (:userId IS NULL Or account0_.user_id = :userId)
不知道是否是由于版本变化与否。
有人可以提供一些线索吗?
account entity code:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
@NotFound(action = NotFoundAction.IGNORE)
private User user;
user entity code:
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Account> account = new ArrayList<>();
the repository cusotom method query annotion
@Query(value = "FROM Account a WHERE (:userId IS NULL Or a.user.id = :userId))
It generates this query:
from account account0_ cross join user user1_ where account0_.user_id=user1_.id and (? is null or user1_.id=?)
It worked fine before I updating springboot from 2.1.4.release to 2.6.5
which is expected to be the following:
from account account0_ WHERE (:userId IS NULL Or account0_.user_id = :userId)
Don't know if it's due to the version change or not.
Can someone give some clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是JPA上的疾病行为
如果您使用以上宣言, ,
删除这将是正常行为。
It's a stange behavior on JPA if you use
this above annotion,
remove this will behave normally.