1

GemfireRepository 是 CrudRepository 的 gemfire 特定实现,但 spring data gemfire 参考指南说,如果我们使用 GemfireRepository,那么我们需要将我们的域类正确映射到配置的区域,否则 bottstrap 进程将失败..这是否意味着我们需要拥有域类上的 @Region 注释?如果我们使用 CrudRepository 则不需要 @Region 注释,因为 CrudRepository 不依赖于 Region ?

所以我正在使用 GemfireRepository 并且我有一个缓存加载器配置为插入到一个区域中,并且缓存加载器依赖于 GemfireRepository 从 RDBMS 获取数据。因此,根据参考文档,如果 GemfireRepository 内部依赖于 Region..那么这会创建循环依赖吗?

4

1 回答 1

0

SDG GemfireRepository 接口扩展了 SDC 的 CrudRepository 接口并添加了几个方法(findAll(:Sort) 和重载的 save(:Wrapper):T 方法),请参阅...

http://docs.spring.io/spring-data-gemfire/docs/current/api/org/springframework/data/gemfire/repository/GemfireRepository.html

GemfireRepository 接口由 SimpleGemfireRepository 类“支持”。

您的应用程序特定的 Repository 接口是否扩展 GemfireRepository 或 CrudRepository,甚至只是 org.springframework.data.repository.Repository,并不重要。扩展由框架提供的 Repository 接口仅决定由框架创建的“代理”在支持实现中公开哪些方法。

例如,如果你想创建一个只读 Repo,你可以直接扩展 org.springframework.data.repository.Repository,并且只将 CrudRepository 接口中的“只读”方法复制到你的应用程序特定的 Repository 接口中(例如 findOne (:ID)、findAll()、exists(:ID),即没有数据存储变异方法,如save(:S):S)。

但是,通过在 Spring 配置中使用命名空间元素,您将指示框架使用 SDG 的存储库基础架构来处理应用程序域对象到 GemFire 的持久操作,特别是区域。因此,要么应用程序域对象必须使用@Region 注释,要么现在,SDG 允许应用程序存储库接口使用@Region 注释,以防您希望应用程序域对象需要存储在 GemFire 的多个区域中。有关详细信息,请参阅 SDG 参考指南中的 8.1,实体映射。

http://docs.spring.io/spring-data-gemfire/docs/1.4.0.RELEASE/reference/html/mapping.html#mapping.entities

关于“循环依赖”......是的,它创建了一个循环依赖......

区域 A -> CacheLoader A -> ARepository -> 区域 A。

并且会导致...

org.springframework.beans.factory.BeanCurrentlyInCreationException

你需要打破这个循环。

于 2014-06-27T08:17:42.683 回答