'literal value cannot be null; nested exception is java.lang.IllegalArgumentException while using Specifications
while fetching data using specification, im getting the following error:
org.springframework.dao.InvalidDataAccessApiUsageException: literal value cannot be null; nested exception is java.lang.IllegalArgumentException: literal value cannot be null
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:374)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:235)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:548)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
this is the code snippet am using :
studentDao.findAll(
(root, query, criteriaBuilder) -> criteriaBuilder.between(
root.get("enrollmentDate"), searchRequest.getStartDate(),
searchRequest.getEndDate()));
so the requirement is to fetch all the student information for a given date range.
my dao is as follows
@Repository
public interface StudentDao extends BaseRepository<StudentEntity, Long>,
JpaSpecificationExecutor<StudentEntity>{
}
Also note that when i tested using unit test the criteria was giving the result, but its failing on my dev environment
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
