Spring Data JPA 1.11 now supports the exists
projection in repository query derivation.
See documentation here.
In your case the following will work:
public interface MyEntityRepository extends CrudRepository<MyEntity, String> {
boolean existsByFoo(String foo);
}
More Related Contents:
- JPQL Create new Object In Select Statement – avoid or embrace?
- How to fetch FetchType.LAZY associations with JPA and Hibernate in a Spring Controller
- How to use multiple JOIN FETCH in one JPQL query
- Doing an “IN” query with Hibernate
- How can I avoid the Warning “firstResult/maxResults specified with collection fetch; applying in memory!” when using Hibernate?
- IN-clause in HQL or Java Persistence Query Language
- Delete Not Working with JpaRepository
- FetchMode join makes no difference for ManyToMany relations in spring JPA repositories
- How to properly use findBySomeOtherId not findById in Spring data jpa?
- Hibernate throws MultipleBagFetchException – cannot simultaneously fetch multiple bags
- Hibernate Annotations – Which is better, field or property access?
- Hibernate JPA Sequence (non-Id)
- How to store date/time and timestamps in UTC time zone with JPA and Hibernate
- What is this spring.jpa.open-in-view=true property in Spring Boot?
- Bypass GeneratedValue in Hibernate (merge data not in db?)
- How does the FetchMode work in Spring Data JPA
- Hibernate – @ElementCollection – Strange delete/insert behavior
- JPA SQL Server No Dialect mapping for JDBC type: -9
- Can I combine a @Query definition with a Specification in a Spring Data JPA repository method?
- Multiple fetches with EAGER type in Hibernate with JPA
- Could not commit JPA transaction: Transaction marked as rollbackOnly
- Spring JpaRepository – Detach and Attach entity
- Using the JPA Criteria API, can you do a fetch join that results in only one join?
- java.lang.IllegalStateException: Multiple representations of the same entity with @ManyToMany 3 entities
- JPA: what is the proper pattern for iterating over large result sets?
- How do I properly do a background thread when using Spring Data and Hibernate?
- Error creating bean with name ‘entityManagerFactory
- How to force Hibernate to return dates as java.util.Date instead of Timestamp?
- JPA Select latest instance for each item
- Spring Data + JPA with multiple datasources but only one set of Repositories