Hello,
We just updated the version of spring boot from 3.4.2 to 3.4.3 and we detected an issue with the annotation @Query.
Here is the request:
@Query(
value =
"select base.id as id, " //
+ "base.createdAt as creationDate, " //
+ "base.accountableId as accountableId, " //
+ "base.identifier as identifier, " //
+ "base.status as status, " //
+ "base.culture as culture, " //
+ "baseb.socialReason as socialReason " //
+ "FROM BASE base " //
+ "INNER JOIN BaseB baseb ON baseb.id = base.companyId "
+ "WHERE (:accountableId IS NULL OR CAST( base.accountableId as text ) = :accountableId ) " //
+ "AND ((:#{#culture == null} = true) OR base.culture IN (:culture)) " //
+ "AND ("
+ "(:identifier IS NULL AND :socialReason IS NULL) "
+ "OR baseb.identifier LIKE %:identifier% "
+ " OR baseb.socialReason LIKE %:socialReason% )" //
+ "AND ((:#{#status == null} = true) OR base.status in (:status) ) ")
Page<BaseResume> getBaseByFilter(
@Param("identifier") final String identifier,
final List<SomeEnum> status,
final String accountableId,
final List<SomeEnumWithString> culture,
final String socialReason,
Pageable pageable);
Before spring 3.4.3 we didn't have any problems with "socialReason" or "identifier" is null, but since spring 3.4.3 it raises an error:
org.springframework.dao.InvalidDataAccessResourceUsageException: No argument for named parameter ':identifier_1'
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:298)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:241)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:560)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:343)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:160)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:223)
at jdk.proxy2/jdk.proxy2.$Proxy207.getAccreditationByFilter(Unknown Source)
at getBaseByFilter
We tries to rollback and the issue disappeared. Do you have any idea about what happens ?
Comment From: nosan
Hi @leo3620, It has already been fixed. See https://github.com/spring-projects/spring-data-jpa/issues/3784
Comment From: wilkinsona
Thanks, @nosan.