如何使用Spring Data JDBC处理复合键 [英] How to handle compound keys with Spring Data JDBC
问题描述
我正在尝试使用Spring Data JDBC访问具有复合键的表,尽管我可以找到很多有关Spring Data JPA如何处理此信息的信息,但似乎不适用于Spring Data JDBC .
I'm trying to use Spring Data JDBC to access a table that has a compound key, and although I can find lots of info on how Spring Data JPA handles this, the same doesn't seem to apply to Spring Data JDBC.
任何人都可以举一个简单的示例,说明如何使用Spring Data JDBC声明实体/存储库以与具有复合主键的表进行对话吗? (例如,两个字符串)
Can anyone give a quick example of how you need to declare an Entity/Repository with Spring Data JDBC to talk to a table with a compound primary key ? (Eg. Two Strings)
推荐答案
当前无法使用CrudRepository作为复合键(版本1.0.2).
Using the CrudRepository for compound keys is currently (Version 1.0.2) not possible.
当然,您仍然可以使用带有@Query
注释的方法.
Of course, you can still use methods annotated with @Query
.
这篇关于如何使用Spring Data JDBC处理复合键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!