I don't know how to do it. I tried this way.
public interface FoodRepository<E extends Object> extends JpaRepository<E, Long>, JpaSpecificationExecutor<E> {
}
@Log4j2
@Service
public class FoodService {
@Autowired
private FoodRepository<FoodAudEntity> afoodRepository;
private final EntityManager entityManager;
public foodService(EntityManager entityManager) {
this.entityManager = entityManager;
}
}
So I need a generic repository for many types of food. I got error as this:-
Error creating bean with name 'FoodService': Unsatisfied dependency expressed through field 'foodRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'foodRepository' defined in com.test.FoodRepository defined in @EnableJpaRepositories declared on JpaConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Object
How can I implement this? is there anyway to do it?
FoodAudEntity class:-
@Entity
@Table(name = "FOOD_AUD_ENTITY")
public class FoodAudEntity{
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@Version
@Column(name = "version")
private Long version;
@Column(name = "name")
private String name;
}