Spring Data JDBC 中的 #{#entityName} 的替代方式

huangapple go评论46阅读模式
英文:

SpEL #{#entityName} alternative in Spring Data JDBC

问题

抱歉,我只提供中文翻译。以下是您提供的英文内容的中文翻译:

我正在扩展一个基础存储库,其中包含跨实体的共享查询,但不幸的是,Spring不支持Spring Data JDBC中的派生删除查询。

我不得不在我的所有存储库中编写自定义查询:

@Modifying
@Query("DELETE FROM table WHERE user=:user AND id=:id")
void deleteByUserAndId(@Param("user") int user, @Param("id") Integer id);

是否有一种方法可以让Spring将实体名称映射到查询中,就像在这里找到的 #{#entityName} 一样?

谢谢。

英文:

I am extending a base repository with shared queries across entities but unfortunately spring does not support derived delete queries in spring data jdbc.

I had to write a custom query in all my repositories:

@Modifying
@Query("DELETE FROM table WHERE user=:user AND id=:id")
void deleteByUserAndId(@Param("user") int user, @Param("id") Integer id);

Is there a way to get spring to map the entity name into the query like #{#entityName} found here.

Thank you.

答案1

得分: 0

对不起,目前没有这样的功能。我也认为没有关于这个功能的请求。请随时创建一个请求来要求此功能。

英文:

No, there is currently no such feature. I also don't think there exists a feature request for this. Feel free to create a ticket asking for it.

huangapple
  • 本文由 发表于 2023年6月12日 22:42:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76457765.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定