Reputation: 43
I want something just like this...i know someone will get it what i want
public interface PersonneRepo extends JpaRepository<T, Long> {
@Query("Select p.name, p.surname, p.age, p.city, p.street from "+T+" p where p.nom = ?1 and p.prenom = ?2")
public T customRequest(String nom, String prenom,String T);
}
Upvotes: 0
Views: 4516
Reputation: 183
public interface PersoRepo<T> extends JpaRepository<T, Long> {
@Query("Select p.name, p.surname, p.age, p.city, p.street from #{#entityName} p where p.nom = :nom and p.prenom = :prenom")
public T customRequest(@Param("nom") String nom, @Param("prenom") String prenom);
}
Upvotes: 1
Reputation: 81882
This are three questions:
How to make a repository with a dynamic type parameter
How to make a query with dynamic from clause.
How to make a query method with dynamic return type.
The last you can do with dynamic projections but it will only convert/wrap the result in a proxy of the desired type so that most likely won't really help you.
Number 2 you can do by writing a custom method implementation using the Criteria API.
Number 1 is a duplicate of this question.
Upvotes: 0