首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Spring @Repository应该遵循JpaRepository吗?

Spring @Repository应该遵循JpaRepository吗?
EN

Stack Overflow用户
提问于 2020-10-11 18:06:31
回答 1查看 59关注 0票数 4

我想在没有数据库连接的情况下将数据存储在HashMap<>或ArrayList<>中。此外,我还想创建一个管理数据的类,比如按条件更新或获取数据。

在这种情况下,创建和使用存储库而不使用JpaRepository是否合适?或者有其他合适的方式吗?

代码语言:javascript
运行
复制
@Repository
public interface ProductRepository  {
    private List<Product> productList; // = new ArrayList<>();

    public Product getProductByid(int id) { ... };
    public boolean updateProduct() { ... };
}
EN

回答 1

Stack Overflow用户

发布于 2020-10-11 18:31:58

您应该看看Spring Data Key Value文档:https://docs.spring.io/spring-data/keyvalue/docs/current/reference/html/#reference

Spring Data Key Value适用于使用键值存储的Spring应用程序。

下面是一个简单的例子:http://www.henryxi.com/spring-data-keyvalue-example

EDIT: As doctore在注释中正确陈述,此示例更适合您的情况:https://www.baeldung.com/spring-data-key-value

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64302807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档