@Retention(value=RUNTIME) @Target(value=TYPE) public @interface Finder
A Finder is a CQRS (Command Query Responsibility Segregation) concept that focus on "Read" part of the architecture. It will return DTO or Representation of Entities.
Main reasons are scalability and coupling decrease. Be sure to follow CAST Training : "Business Framework".
@Finder
public interface FooFinder {
List<FooDto> findFoosWithName(String name);
}
2) Then, create the implementation of this interface.
@Finder
public class JpaFooFinder implements FooFinder {
@Inject
EntityManager entityManager;
List<FooDto> findFoosWithName(String name) {
entityManager.createQuery(...);
return query.getResultList();
}
3) Finally, SEED will automatically provide the injection of the Interface
@Inject private FooFinder fooFinder; - - - - @Inject public void provideFinder (FooFinder fooFinder) - - - - fooFinder.findFoosWithName(nameToFind);
Copyright © 2013-2016–2016 SeedStack. All rights reserved.