Opened 6 months ago

Closed 6 months ago

#2113 closed defect (fixed)

QueryException in annotation importer plug-in

Reported by: nicklas Owned by: everyone
Priority: critical Milestone: BASE 3.12.2
Component: core Version:
Keywords: Cc:

Description

It seems like the bugfix for #2110 didn't catch all cases. I got a very similar exception again:

net.sf.basedb.core.BaseException: org.hibernate.QueryException: Named parameter does not appear in Query: 
  listOfIds [SELECT "id", "value" FROM "BooleanValues" WHERE "id" IN (?, ?)] 
  at net.sf.basedb.core.HibernateUtil.loadList(HibernateUtil.java:2066) 
  at net.sf.basedb.core.AnnotationBatcher.setCurrentItem(AnnotationBatcher.java:635) 
  at net.sf.basedb.plugins.AnnotationFlatFileImporter$NewAnnotations.setNewAnnotations(AnnotationFlatFileImporter.java:1408) 
  at net.sf.basedb.plugins.AnnotationFlatFileImporter.end(AnnotationFlatFileImporter.java:958) 
  at net.sf.basedb.plugins.AbstractFlatFileImporter.doImport(AbstractFlatFileImporter.java:739) 
  at net.sf.basedb.plugins.AnnotationFlatFileImporter.doImport(AnnotationFlatFileImporter.java:651) 
  at net.sf.basedb.plugins.AbstractFlatFileImporter.run(AbstractFlatFileImporter.java:451) 
  at net.sf.basedb.core.PluginExecutionRequest.invoke(PluginExecutionRequest.java:117) 
  at net.sf.basedb.core.InternalJobQueue$JobRunner.run(InternalJobQueue.java:573) 
  at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: Named parameter does not appear in Query: 
  listOfIds [SELECT "id", "value" FROM "BooleanValues" WHERE "id" IN (?, ?)] 
  at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:131) 
  at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) 
  at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423) 
  at net.sf.basedb.core.hibernate.QueryWrapper.list(QueryWrapper.java:137) 
  at net.sf.basedb.core.HibernateUtil.loadList(HibernateUtil.java:2062) 
  ... 9 more 
Caused by: org.hibernate.QueryException: Named parameter does not appear in Query: 
  listOfIds [SELECT "id", "value" FROM "BooleanValues" WHERE "id" IN (?, ?)] 
  at org.hibernate.loader.custom.CustomLoader.getNamedParameterLocs(CustomLoader.java:463) 
  at org.hibernate.loader.Loader.bindNamedParameters(Loader.java:2091) 
  at org.hibernate.loader.Loader.bindParameterValues(Loader.java:2022)
  at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1956) 
  at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1909) 
  at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1887) 
  at org.hibernate.loader.Loader.doQuery(Loader.java:932) 
  at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) 
  at org.hibernate.loader.Loader.doList(Loader.java:2615) 
  at org.hibernate.loader.Loader.doList(Loader.java:2598) 
  at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2430) 
  at org.hibernate.loader.Loader.list(Loader.java:2425) 
  at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:335) 
  at org.hibernate.internal.StatelessSessionImpl.listCustomQuery(StatelessSessionImpl.java:574) 
  at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:992) 
  at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:148) 
  at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) 
  ... 11 more

Initial debugging shows that the fix is working most of the time since the annotation importer progress a bit further than before. The exception seems to be triggered when the query is repeated after the list contained one parameter value. In this case Hibernate doesn't generate any "synthetic" parameters but simply copies the original one. For example:

When the list contains two value we get: listOfIds_0 and listOfIds_1 These are cleared by our fix which looks for listOfIds_*.

When the list contains only a single value we get: listOfIds (without the _0 suffix) This is not cleared by or fix so the next time the query is re-used (with more than one value) the exceptions is triggered.

Change History (1)

comment:1 Changed 6 months ago by nicklas

  • Resolution set to fixed
  • Status changed from new to closed

(In [7473]) Fixes #2113: QueryException? in annotation importer plug-in

We need to also remove the parameter without a suffix if it is found.

Note: See TracTickets for help on using tickets.