When using the new Spring Data Evans release it\'s nice to be able to use some of the nice stuff that came with java 8. One of them is default implementations in interfaces. The
You don't get the EntityManager
in an interface, although you might be able to work around it by doing a lookup.
But why are you even doing this? Spring Data JPA already supports the Optional
return type so you don't need to implement it. Spring Data will do it for you.
public interface UserRepository extends JpaRepository {
Optional findByLoginIgnoreCase(String login) {
}
The code above should be all you need. You could even specify a query with @Query
if you would need it.
A Sample can be found here.