Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

CDI Integration: Generics

$
0
0
I'm trying to implement a crud controller using a generic repository interface like this:

Code:

public interface ProjetoRepository extends JpaRepository<Projeto, Integer>, Serializable {
}

public abstract class CrudController<T, ID extends Serializable> implements Serializable {
@Inject
private JpaRepository<T, ID> repository;
}

@Model
@ConversationScoped
public class ProjetoCrudController extends CrudController<Projeto, Integer> {
    public ProjetoCrudController() {
        super(Projeto.class);
    }
}

The problem is that @Inject JpaRepository<T, ID> is not resolved:

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [JpaRepository<Projeto, Integer>] with qualifiers [@Default] at injection point [[field] @Inject private CrudController.repository]

I have a similar implementation with a concret class (without spring-data) that works in this scenario. This is a limitation of proxy mechanism of spring-data or I'm missing something?

Viewing all articles
Browse latest Browse all 297

Trending Articles