Skip to content

Provide entity context for repository fragments [DATACMNS-1134] #1576

Open
@spring-projects-issues

Description

@spring-projects-issues

Mark Paluch opened DATACMNS-1134 and commented

TL;DR:

Provide an entity context for repository fragments (Inject RepositoryMetadata or a smaller interface).

Explanation

Composable repositories allow a composition model that is much more decoupled from the original repository than the previous single custom implementation model. Custom implementations are no longer required to follow RepositoryNameCustom and RepositoryNameImpl but can have names decoupled from the repository itself.

This degree of freedom allows reuse of implementations across multiple repositories:

interface UserRepository implements Repository<User, String>, SoftDeletingRepository<User>{}
interface PersonRepository implements Repository<Person, String>, SoftDeletingRepository<Person>{}

From the example above, SoftDeletingRepository is a fragment which is used in multiple repositories and depending on its functionality, the fragment would require an entity context to perform its actions.

The difficulty is, that fragment instances are passed into a repository factory, and the entity context is created at a later time when the repository is instantiated. Fragments could be reused across multiple factory beans creating a shared mutable state.


No further details from DATACMNS-1134

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions