Closed filpet90 closed 1 year ago
Good morning. Yes, I have this issue too!
I can only say that it is happen when it's only one character on the search input, very rare error. When you put more than one character, there's no error.
Just for the record, I'm working on Angular 15 with angular-datatables setting "server-side" options: https://l-lin.github.io/angular-datatables/#/basic/new-server-side
- No character at input "search" (No error on Spring Boot):
- Only one character at input "search" (Error on Spring Boot): `2023-02-09T09:37:21.066-05:00 WARN 12492 --- [nio-8085-exec-2] o.s.d.j.d.r.DataTablesRepositoryImpl : error while fetching records
java.lang.IllegalArgumentException: Already registered a copy: SqmBasicValuedSimplePath(com.basewarnet.ungrd.models.tipos.ClaseContrato(268069621620900).codigoClaseContrato)
at org.hibernate.query.sqm.tree.SqmCopyContext$1.registerCopy(SqmCopyContext.java:33) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath.copy(SqmBasicValuedSimplePath.java:52) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath.copy(SqmBasicValuedSimplePath.java:25) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.copy(SelfRenderingSqmFunction.java:68) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.copy(SelfRenderingSqmFunction.java:37) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.copy(SelfRenderingSqmFunction.java:68) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.copy(SelfRenderingSqmFunction.java:37) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmLikePredicate.copy(SqmLikePredicate.java:90) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmLikePredicate.copy(SqmLikePredicate.java:19) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.copy(SqmJunctionPredicate.java:54) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.copy(SqmJunctionPredicate.java:21) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.copy(SqmJunctionPredicate.java:54) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.copy(SqmJunctionPredicate.java:21) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.predicate.SqmWhereClause.copy(SqmWhereClause.java:33) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.select.SqmQuerySpec.copy(SqmQuerySpec.java:104) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.select.SqmQuerySpec.copy(SqmQuerySpec.java:53) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.select.SqmSelectStatement.copy(SqmSelectStatement.java:122) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.tree.select.SqmSelectStatement.copy(SqmSelectStatement.java:42) ~[hibernate-core-6.1.6.Final.jar:6.1.6.Final]
at org.hibernate.query.sqm.internal.QuerySqmImpl.
{ "draw" : 23, "recordsTotal" : 27, "recordsFiltered" : 0, "data" : [ ], "searchPanes" : null, "error" : "java.lang.IllegalArgumentException: Already registered a copy: SqmBasicValuedSimplePath(com.basewarnet.ungrd.models.tipos.ClaseContrato(268069621620900).codigoClaseContrato)" } 2023-02-09T09:37:21.144-05:00 ERROR 12492 --- [nio-8085-exec-2] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/ungrd] threw exception [Request processing failed: org.springframework.transaction.UnexpectedRollbackException: Transaction silently rolled back because it has been marked as rollback-only] with root cause
org.springframework.transaction.UnexpectedRollbackException: Transaction silently rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:752) ~[spring-tx-6.0.4.jar:6.0.4]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) ~[spring-tx-6.0.4.jar:6.0.4]
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654) ~[spring-tx-6.0.4.jar:6.0.4]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407) ~[spring-tx-6.0.4.jar:6.0.4]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-6.0.4.jar:6.0.4]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) ~[spring-aop-6.0.4.jar:6.0.4]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:752) ~[spring-aop-6.0.4.jar:6.0.4]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703) ~[spring-aop-6.0.4.jar:6.0.4]
at com.basewarnet.ungrd.services.tipos.ClaseContratoService$$SpringCGLIB$$0.getList(
- More than one character at input "search" (No error on Spring Boot):
In our case, there are "good" characters, e.g. 'c', 'm', '1' works fine. Putting 'e' into the search input causes this error, but 'el' and 'en' are fine again. We also have another table (which shows another entity) where the inputs 'e', 'el' or 'm', 'me' are bad, but 'meg' works. Finally, we have at least two tables where we have not experienced this problem.
Hi! I'm digging into this, I will try to reproduce the issue locally.
Possibly related: https://stackoverflow.com/questions/74262361/error-when-trying-to-filter-data-in-spring-boot/75172780#75172780
We found some Hibernate issues that might be related to this problem: https://hibernate.atlassian.net/browse/HHH-15951 https://hibernate.atlassian.net/browse/HHH-16014
Hmm, so the error is thrown at line 85:
Are you using a preFilteringSpecification
?
Else, it seems https://hibernate.atlassian.net/browse/HHH-16014 was fixed in 6.1.7
, could you please check the exact version of your hibernate-core
dependency?
We don't use preFilteringSpecification. For the first problematic table, we use the simple DataTablesRepository.findAll(DataTablesInput input) method. In case of the other table, there is an additionalSpecification parameter.
We have tried all Hibernate versions above 6.0.0. (e.g. 6.1.6, 6.1.7 and 6.2.0.CR2). Unfortunately none of them helped us. 6.1.7 give us a different exception:
error while fetching records jakarta.persistence.PersistenceException: Converting
org.hibernate.sql.ast.SqlTreeCreationException
to JPAPersistenceException
: Could not locate TableGroup - xx.yy.zz.adatbazis.Rendszeresemeny(2597513621354900) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165) at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:374) at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:1073) at org.hibernate.query.Query.getResultList(Query.java:94) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.executeCountQuery(SimpleJpaRepository.java:868) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.lambda$readPage$4(SimpleJpaRepository.java:690) at org.springframework.data.support.PageableExecutionUtils.getPage(PageableExecutionUtils.java:63) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:689) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:471) at org.springframework.data.jpa.datatables.repository.DataTablesRepositoryImpl.findAll(DataTablesRepositoryImpl.java:85) at org.springframework.data.jpa.datatables.repository.DataTablesRepositoryImpl.findAll(DataTablesRepositoryImpl.java:41) ...
Exception in case of 6.2.0.CR2 version is also a little bit different:
error while fetching records org.hibernate.sql.ast.SqlTreeCreationException: Could not locate TableGroup - xx.yy.zz.adatbazis.Rendszeresemeny(2597764189620200) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3398) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3392) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3346) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3335) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitBasicValuedPath(BaseSqmToSqlAstConverter.java:3970) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitBasicValuedPath(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath.accept(SqmBasicValuedSimplePath.java:132) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitWithInferredType(BaseSqmToSqlAstConverter.java:6433) at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.resolveSqlAstArguments(SelfRenderingSqmFunction.java:132) at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.convertToSqlAst(SelfRenderingSqmFunction.java:144) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitFunction(BaseSqmToSqlAstConverter.java:5675) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitFunction(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.expression.SqmFunction.accept(SqmFunction.java:66) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitWithInferredType(BaseSqmToSqlAstConverter.java:6433) at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.resolveSqlAstArguments(SelfRenderingSqmFunction.java:132) at org.hibernate.query.sqm.function.SelfRenderingSqmFunction.convertToSqlAst(SelfRenderingSqmFunction.java:144) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitFunction(BaseSqmToSqlAstConverter.java:5675) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitFunction(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.expression.SqmFunction.accept(SqmFunction.java:66) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitWithInferredType(BaseSqmToSqlAstConverter.java:6420) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitLikePredicate(BaseSqmToSqlAstConverter.java:6909) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitLikePredicate(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.predicate.SqmLikePredicate.accept(SqmLikePredicate.java:120) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitJunctionPredicate(BaseSqmToSqlAstConverter.java:6599) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitJunctionPredicate(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.accept(SqmJunctionPredicate.java:74) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitJunctionPredicate(BaseSqmToSqlAstConverter.java:6586) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitJunctionPredicate(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.predicate.SqmJunctionPredicate.accept(SqmJunctionPredicate.java:74) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitWhereClause(BaseSqmToSqlAstConverter.java:2465) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:2051) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQuerySpec(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.select.SqmQuerySpec.accept(SqmQuerySpec.java:122) at org.hibernate.query.sqm.spi.BaseSemanticQueryWalker.visitQueryPart(BaseSemanticQueryWalker.java:226) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitQueryPart(BaseSqmToSqlAstConverter.java:1907) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:1592) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitSelectStatement(BaseSqmToSqlAstConverter.java:424) at org.hibernate.query.sqm.tree.select.SqmSelectStatement.accept(SqmSelectStatement.java:222) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.translate(BaseSqmToSqlAstConverter.java:755) at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.buildCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:370) at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:290) at org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:266) at org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:519) at org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:367) at org.hibernate.query.sqm.internal.QuerySqmImpl.list(QuerySqmImpl.java:1079) at org.hibernate.query.Query.getResultList(Query.java:119) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.executeCountQuery(SimpleJpaRepository.java:868) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.lambda$readPage$4(SimpleJpaRepository.java:690) at org.springframework.data.support.PageableExecutionUtils.getPage(PageableExecutionUtils.java:63) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.readPage(SimpleJpaRepository.java:689) at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:471) at org.springframework.data.jpa.datatables.repository.DataTablesRepositoryImpl.findAll(DataTablesRepositoryImpl.java:85) at org.springframework.data.jpa.datatables.repository.DataTablesRepositoryImpl.findAll(DataTablesRepositoryImpl.java:41) ...
Good morning from Bogotá, Colombia!
No. I'm just using repository.findAll(DataTablesInput input), no filters, no specification. Nothing else. In fact, I have seen that when I enter only some characters in the input search of the Datatable, the error comes... These characters are producing the error: "e", "r", "t", "i", "o", "a", "s", "d", "c", "v", "n", "1", "0". Just one character at time, that's what I mean.
This is what service class receives from the Angular datatable when I enter the "e" character:
{ "draw" : 86, "start" : 0, "length" : 10, "search" : { "value" : "e", "regex" : false }, "order" : [ { "column" : 0, "dir" : "asc" } ], "columns" : [ { "data" : "codigoClaseContrato", "name" : "codigoClaseContrato", "searchable" : true, "orderable" : true, "search" : { "value" : "", "regex" : false } }, { "data" : "nombreClaseContrato", "name" : "nombreClaseContrato", "searchable" : true, "orderable" : true, "search" : { "value" : "", "regex" : false } } ], "searchPanes" : null, "columnsAsMap" : { "nombreClaseContrato" : { "data" : "nombreClaseContrato", "name" : "nombreClaseContrato", "searchable" : true, "orderable" : true, "search" : { "value" : "", "regex" : false } }, "codigoClaseContrato" : { "data" : "codigoClaseContrato", "name" : "codigoClaseContrato", "searchable" : true, "orderable" : true, "search" : { "value" : "", "regex" : false } } } }
The service class has these anotations:
@Service @Transactional
By the way, in my case, the locale language is es-CO and the Default Encoding is "ISO-8859-1".
Thanks a lot!!!!
Awesome! Thank you for your work, in our case it's working now without any problems!
@filpet90 thanks a lot for the feedback :heart:
I think this should be fixed by https://github.com/darrachequesne/spring-data-jpa-datatables/commit/a6a8a0d9d97919e8321927ac4f35078844cdfa26, included in version 6.0.1
. The randomness was due to whether the optional count query was run, depending on the number of results returned by the data query.
I've updated the sample project with Spring Boot 3, all seem to work well now: https://github.com/darrachequesne/spring-data-jpa-datatables-sample
Please reopen if needed.
We have migrated our application to Spring Boot 3.0.2 using Hibernate 6.1 and Datatables 6.0.0. After the migration, the filtering function of some tables no longer works. We get different ORM related exceptions like "Already registered a copy: SqmBasicValuedSimplePath" or "Already registered a copy: SqmSingularJoin" (stack trace below)