Project

General

Profile

Actions

bug #9642

closed

hibernate.QueryException in OccurrenceDaoHibernateImpl.countMedia()

Added by Andreas Kohlbecker over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Highest
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal
Found in Version:

Description

12:55:00.629 [flora-malesiana] [qtp1511785794-17712] INFO  e.e.c.r.c.DerivedUnitFacadeController - doGetFieldObjectMediaDTO() - /flora-malesiana/derivedUnitFacade/bf6da482-ace7-4029-8182-67c823a46274/fieldObjectMediaDTO
12:55:00.645 [flora-malesiana] [qtp1511785794-17712] WARN  e.e.cdm.servlet.DateHeaderFilter - Can not add data header.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.QueryException: could not resolve property: media of: eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase [SELECT count(media) FROM eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase occurence JOIN occurence.media media WHERE occurence = :occurence]



Caused by: org.hibernate.QueryException: could not resolve property: media of: eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase [SELECT count(media) FROM eu.etaxonomy.cd
m.model.occurrence.SpecimenOrObservationBase occurence JOIN occurence.media media WHERE occurence = :occurence]
        at org.hibernate.QueryException.generateQueryException(QueryException.java:120)
        at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:217)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:141)
        at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
        at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
        at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
        at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
        at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
        at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
        at eu.etaxonomy.cdm.persistence.dao.hibernate.occurrence.OccurrenceDaoHibernateImpl.countMedia(OccurrenceDaoHibernateImpl.java:136)
        at eu.etaxonomy.cdm.api.service.OccurrenceServiceImpl.getMediaDTOs(OccurrenceServiceImpl.java:201)
        at sun.reflect.GeneratedMethodAccessor8934.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:283)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
        at com.sun.proxy.$Proxy6843.getMediaDTOs(Unknown Source)
        at eu.etaxonomy.cdm.remote.controller.DerivedUnitFacadeController.lambda$doGetFieldObjectMediaDTO$0(DerivedUnitFacadeController.java:115)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at eu.etaxonomy.cdm.remote.controller.DerivedUnitFacadeController.doGetFieldObjectMediaDTO(DerivedUnitFacadeController.java:117)
        at sun.reflect.GeneratedMethodAccessor8812.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:854)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:765)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
Actions #1

Updated by Andreas Kohlbecker over 1 year ago

  • Subject changed from hibernate.QueryException in derivedUnitFacade/{uuid}/fieldObjectMediaDTO to hibernate.QueryException in OccurrenceDaoHibernateImpl.countMedia()
  • Category changed from cdmlib-remote to cdmlib
  • Assignee changed from Andreas Kohlbecker to Andreas Müller
Actions #2

Updated by Andreas Müller over 1 year ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50
Actions #3

Updated by Andreas Müller over 1 year ago

  • Assignee changed from Andreas Müller to Andreas Kohlbecker
  • Target version changed from Release 5.25 to Release 5.24

The method countMedia and getMedia in OccurrenceImpl was not correctly updated after media was removed from SpecimenOrObservationBase years ago.
I updated the method to collect all media attached to a SpecimenOrObservationBase via an ImageGallery and, if the specimen is a MediaSpecimen, the media for the media specimen.

Actions #4

Updated by Andreas Müller over 1 year ago

please review

Actions #5

Updated by Andreas Kohlbecker over 1 year ago

  • Assignee changed from Andreas Kohlbecker to Andreas Müller

In principle OK. In case of MediaSpecimens the list of Media ids collected by getMediaIds() is sorted twice: fist by the mysql server, then by the cdmlib. This can be avoided by the following change:

  • remove: ORDER BY m.id
  • move Collections.sort(list); out of the if statement block right above the return.

I guess there is still a test to be adapted?

The ticket can be closed, once these two points are handled

Actions #6

Updated by Andreas Müller over 1 year ago

  • Assignee changed from Andreas Müller to Andreas Kohlbecker

Andreas Kohlbecker wrote:

In principle OK. In case of MediaSpecimens the list of Media ids collected by getMediaIds() is sorted twice: fist by the mysql server, then by the cdmlib. This can be avoided by the following change:

  • remove: ORDER BY m.id
  • move Collections.sort(list); out of the if statement block right above the return.

I guess there is still a test to be adapted?

The ticket can be closed, once these two points are handled

This is somehow true but there is a reasons for doing it the way it is implemented:

Ordering takes place in mysql anyway due to "DISTINCT", therefore there is no overhead for order by in SQL.
But there is a (small) overhead by running java sort on all specimen, not only the media specimen.

Additionally the media specimen will only add max. 1 id to the list, so even if the above assumption is not true the additional sorting of a mostly presorted list will be extremely small.

I guess there is still a test to be adapted?

whyt exactly do you mean?

Actions #7

Updated by Andreas Müller over 1 year ago

But I removed the order by from the media specimen sql. As this query always returns max 1 result order by is not necessary.

Actions #8

Updated by Andreas Kohlbecker over 1 year ago

  • Status changed from Resolved to Feedback
  • Assignee changed from Andreas Kohlbecker to Andreas Müller

Andreas Müller wrote:

I guess there is still a test to be adapted?

whyt exactly do you mean?

Isn't this related to the "Tests für countMedia" currently being discussed by email?

Actions #9

Updated by Andreas Müller over 1 year ago

  • Assignee changed from Andreas Müller to Andreas Kohlbecker

Andreas Kohlbecker wrote:

Andreas Müller wrote:

I guess there is still a test to be adapted?

whyt exactly do you mean?

Isn't this related to the "Tests für countMedia" currently being discussed by email?

Ahh, you mean the dataportal test? Yes, this is true, this needs to be adapted.

Actions #10

Updated by Andreas Kohlbecker over 1 year ago

  • Status changed from Feedback to Closed
  • Assignee changed from Andreas Kohlbecker to Andreas Müller
  • % Done changed from 50 to 100

Done

Actions

Also available in: Atom PDF