- All Known Subinterfaces:
ORMTemplate
public interface RepositoryLookup
Provides access to repositories.
Entity repositories returned by entity provide basic CRUD operations for database tables. Projection
repositories returned by projection provide read operations for database views and projection queries. The
repositories returned by the repository method
allow to implement specialized repository logic by implementing default methods. The default methods have full access
to the CRUD and QueryBuilder logic of the repository it extends:
interface UserRepository extends EntityRepository<User, Integer> {
default Optional<User> findByName(String name) {
return select().
.where(User_.name, EQUALS, name) // Type-safe metamodel.
.getOptionalResult();
}
default List<User> findByCity(City city) {
return select().
.where(User_.city, city) // Type-safe metamodel.
.getResultList();
}
}- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T extends Entity<ID>,ID>
EntityRepository<T, ID> Returns the repository for the given entity type.<T extends Projection<ID>,ID>
ProjectionRepository<T, ID> projection(Class<T> type) Returns the repository for the given projection type.<R extends Repository>
Rrepository(Class<R> type) Returns a proxy for the repository of the given type.
-
Method Details
-
entity
Returns the repository for the given entity type.- Type Parameters:
T- the entity type.ID- the type of the entity's primary key.- Parameters:
type- the entity type.- Returns:
- the repository for the given entity type.
-
projection
Returns the repository for the given projection type.- Type Parameters:
T- the projection type.ID- the type of the projection's primary key, or Void if the projection specifies no primary key.- Parameters:
type- the projection type.- Returns:
- the repository for the given projection type.
-
repository
Returns a proxy for the repository of the given type.- Type Parameters:
R- the repository type.- Parameters:
type- the repository type.- Returns:
- a proxy for the repository of the given type.
-