I have the following interface:
public interface SnapshotRepository extends JpaRepository<Snapshot, Integer>, ISnapshotRepositoryExtra { }
that as you can see extends:
public interface ISnapshotRepositoryExtra {
Optional<Snapshot> latest();
}
... I've implemented that latest()
method in the following classes:
@Transactional
public class SnapshotRepositoryExtra implements ISnapshotRepositoryExtra {
@PersistenceContext
private EntityManager entityManager;
@Override
public Optional<Snapshot> latest() {
return (Optional<Snapshot>) entityManager
.createQuery("SELECT r FROM snapshot r order by timestamp DESC LIMIT 1")
.getResultStream().findFirst();
}
}
However when I launch the project, I see:
java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Optional com...persistance.snapshot.ISnapshotRepositoryExtra.latest()! No property latest found for type Snapshot!
So my question is, why Spring does not see the class SnapshotRepositoryExtra
that I've just made?