Codium
Codium

Reputation: 3240

Is this a good practice to pass EntityRepository object to other EntityRepository object?

As in questions, I need to merge results from both repositories and I can't do it by SQL.

Is this correct way or maybe I should create service class to handle repositories logic?

Upvotes: 0

Views: 118

Answers (1)

Steven Mercatante
Steven Mercatante

Reputation: 25315

No, it's not good practice. Use a service object to handle any complex operations between two or more result sets from multiple entity repositories. Your repositories should still contain the queries, but a service object should be responsible for merging or filtering them into one final result set.

Upvotes: 2

Related Questions