Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use another repository in a repository? #17

Open
foxbaucia opened this issue Oct 10, 2018 · 2 comments
Open

Can I use another repository in a repository? #17

foxbaucia opened this issue Oct 10, 2018 · 2 comments

Comments

@foxbaucia
Copy link

Having 2 entities i.e. Task and Project where a Project contain a list of taskIds

For Project, I have a
ProjectRepositoryDecorator extends ResourceRepositoryDecoratorBase<T, I>

For Task just the Entity and I configured the repository like:
config.addRepository(JpaRepositoryConfig.builder(TaskEntity.class).build());

Then in the implementation of the create() method for Project I would like to check that the taskIds of a new Project are from task that contains certain property.
My point is how in the ProjectRepositoryDecorator.save() I can access the TaskRepository to do a findOne()?

I tried implementing a TaskRepository extends ReadOnlyResourceRepositoryBase, but when I call the findOne of this instance, the repository has the attribute resourceRegistry null.

@remmeier
Copy link
Contributor

the resource registry is the way to go. make sure to implement that ResourceRegistryAware and setResourceregistry. maybe the method also needs to be invoked on the super type.

dependeny injection in this area is sonething that would be worthwhile to investigate, it is a frequent topic that comes up.

@foxbaucia
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants