Project

General

Profile

Actions

bug #7756

open

org.hibernate.QueryException in portal/taxon/{uuid}/subtree/media.json webservice related to relation direction param in prepareTaxonRelationshipQuery()

Added by Andreas Kohlbecker over 5 years ago. Updated over 5 years ago.

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

80%

Estimated time:
Severity:
normal
Found in Version:

Description

http://api.cybertaxonomy.org/corvidae/portal/taxon/147cb0d4-0f0e-4ba4-a234-e0b55d51677a/subtree/media.json?type=ImageFile&relationships=831fcd88-e5c9-49e0-b06e-bbb67d1c05c9&relationshipsInvers=&includeTaxonDescriptions=1&includeOccurrences=1&includeTaxonNameDescriptions=

throws the exception:

...
Caused by: org.hibernate.QueryException: could not resolve property: null of: eu.etaxonomy.cdm.model.taxon.TaxonRelationship [SELECT  rel  FROM eu.etaxonomy.cdm.model.taxon.TaxonRelationship rel  WHERE rel.null = :relatedTaxon]
    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:218)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
    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:1894)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl.getTaxonRelationships(TaxonDaoHibernateImpl.java:1045)
    at eu.etaxonomy.cdm.api.service.TaxonServiceImpl.collectRelatedTaxa(TaxonServiceImpl.java:572)
    at eu.etaxonomy.cdm.api.service.TaxonServiceImpl.listRelatedTaxa(TaxonServiceImpl.java:538)
    at eu.etaxonomy.cdm.api.service.TaxonServiceImpl.listMedia(TaxonServiceImpl.java:769)
    at sun.reflect.GeneratedMethodAccessor25044.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:302)
    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:281)
    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:208)
    at com.sun.proxy.$Proxy4291.listMedia(Unknown Source)
    at eu.etaxonomy.cdm.remote.controller.TaxonPortalController.getMediaForTaxon(TaxonPortalController.java:635)
    at eu.etaxonomy.cdm.remote.controller.TaxonPortalController.doGetSubtreeMedia(TaxonPortalController.java:587)
    at sun.reflect.GeneratedMethodAccessor25041.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:222)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
    ... 61 more
...

Related issues

Related to EDIT - task #3560: Withheld unpublished taxa from webservice used in E+M dataportalResolvedAndreas Müller

Actions
Actions #1

Updated by Andreas Kohlbecker over 5 years ago

  • Related to task #3560: Withheld unpublished taxa from webservice used in E+M dataportal added
Actions #2

Updated by Andreas Kohlbecker over 5 years ago

the bug was introduced by the e08838f0 for #3560

Actions #3

Updated by Andreas Kohlbecker over 5 years ago

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

Updated by Andreas Kohlbecker over 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 50 to 100
Actions #5

Updated by Andreas Müller over 5 years ago

  • Status changed from Closed to Feedback

Unfortunately the solution is not complete for includeUnpublished = true.

In this case you again get an NPE as you can see IDE warning.

Not sure if the following is correct in all cases:

if direction == null:
  result += " AND rel."+direction.invers()+".publish = :publish AND rel."+direction+".publish = :publish ";

Maybe we need to handle this together with the changes made for this ticket which makes the code complicated.

As this is unclear and as the code that lead to the exception is the ONLY one using direction == null I personally whould prefer to not allow direction == null at all. This is because the calling code will anyway distinguish the 2 cases and this way it becomes all clearer.
The above exception can than easily be handled on higher level by handling these 2 cases as all other calling methods do.
Only we need to make this clear in Javadoc and throw NPE or IAE if direction == null.

Actions #6

Updated by Andreas Müller over 5 years ago

  • % Done changed from 100 to 80
Actions #7

Updated by Andreas Kohlbecker over 5 years ago

Andreas Müller wrote:

Unfortunately the solution is not complete for includeUnpublished = true.

In this case you again get an NPE as you can see IDE warning.

Not sure if the following is correct in all cases:

if direction == null:
  result += " AND rel."+direction.invers()+".publish = :publish AND rel."+direction+".publish = :publish ";

Maybe we need to handle this together with the changes made for this ticket which makes the code complicated.

As this is unclear and as the code that lead to the exception is the ONLY one using direction == null I personally whould prefer to not allow direction == null at all. This is because the calling code will anyway distinguish the 2 cases and this way it becomes all clearer.
The above exception can than easily be handled on higher level by handling these 2 cases as all other calling methods do.
Only we need to make this clear in Javadoc and throw NPE or IAE if direction == null.

What about performance? Isn't it better to do it in one call instead of having to query the DB 2 times?

Actions #8

Updated by Andreas Kohlbecker over 5 years ago

  • Assignee changed from Andreas Kohlbecker to Andreas Müller
Actions

Also available in: Atom PDF