bug #7756
openorg.hibernate.QueryException in portal/taxon/{uuid}/subtree/media.json webservice related to relation direction param in prepareTaxonRelationshipQuery()
80%
Description
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
Updated by Andreas Kohlbecker over 4 years ago
- Related to task #3560: Withheld unpublished taxa from webservice used in E+M dataportal added
Updated by Andreas Kohlbecker over 4 years ago
Updated by Andreas Kohlbecker over 4 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 50
Applied in changeset cdmlib|273b0cdc0b621b1a4314631f83bf9bba9491f9ea.
Updated by Andreas Kohlbecker over 4 years ago
- Status changed from Resolved to Closed
- % Done changed from 50 to 100
Updated by Andreas Müller over 4 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.
Updated by Andreas Kohlbecker over 4 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?
Updated by Andreas Kohlbecker over 4 years ago
- Assignee changed from Andreas Kohlbecker to Andreas Müller