I'm using Quarkus with Hibernate Reactive and Panache REST Data. I'm using the Repository pattern. I would like to use the PanacheRepositoryResource
and add a custom endpoint that calls a method in the EntityRepository
, but I don't know how to inject the entityRepository
since it is an interface.
@ResourceProperties
public interface EntityResource extends PanacheRepositoryResource<EntityRepository, Entity, Long> {
@GET
@Path("/customMethod")
default Uni<List<Entity>> repositoryMethod() {
return entityRepository.customMethod(); // <-- How can I inject my repository?
}
}
Any ideas?
You can do something like this:
@ResourceProperties
public interface EntityResource extends PanacheRepositoryResource<EntityRepository, Entity, Long> {
@GET
@Path("/customMethod")
default Uni<List<Entity>> repositoryMethod() {
return CDI.current().select(EntityRepository.class).get().customMethod();
}
}