public interface ItemRepository extends JpaRepository<Item, Integer> {
List<Item> findByNameAndDescriptionIsNullOrDescription(String name, String desc);
}
In the native Query, the where
condition of findByNameAndDescriptionIsNullOrDescription
is translated to
where item0_.NAME=? and (item0_.DESC is null) or item0_.DESC=?
I need to have where item0_.NAME=? and (item0_.DESC is null or item0_.DESC=?)
I am using the following
spring-data-commons-1.6.3.RELEASE.jar
spring-data-jpa-1.4.3.RELEASE.jar
(i)hibernate-entitymanager-4.2.14.SP1-redhat-1.jar, (ii) hibernate-jpa-2.0-api-1.0.1.Final-redhat-2.jar offered by JBOSS EAP 6.3
Querydsl is a framework that enables the construction of statically typed SQL-like queries through its fluent API. Spring Data modules offer integration with Querydsl through QuerydslPredicateExecutor .
CrudRepository provides CRUD functions. PagingAndSortingRepository provides methods to do pagination and sort records. JpaRepository provides JPA related methods such as flushing the persistence context and delete records in a batch.
The solution is to use @javax. persistence. Version on a new versionNumber column in all the tables. If you have a parent and child table then use @Version column in all the entity classes.
Querydsl is an extensive Java framework, which allows for the generation of type-safe queries in a syntax similar to SQL. It currently has a wide range of support for various backends through the use of separate modules including JPA, JDO, SQL, Java collections, RDF, Lucene, Hibernate Search, and MongoDB.
Probably you can't do that.
Spring Data querydsl is used only for simple SQL queries and if you need something more complex use @Query
annotation.
It also would be easier for other developers to understand what query you used instead of analyzing your method name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With