dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #48666
Re: [Dhis2-users] delete existing data elements
Hi Lorill,
this happens due to a lingering legacy database table. We will include a
startup statement to remove it. In the meantime you can run this SQL
against your database:
drop table caseaggregationcondition;
regards,
Lars
On Tue, Feb 14, 2017 at 11:10 PM, Lorill Crees <lcrees@xxxxxxxxxx> wrote:
> Hi Lars,
>
> I am attempting to delete a data element via the API and am getting the
> below error, due to a foreign key constraint on table
> "caseaggregationcondition".
>
> What are CaseAggregationConditions and where are they in the DHIS 2 UI?
>
> In your prior email to Channara you said that "If you upgrade to a later
> version of DHIS 2, those have been removed completely."
>
> Which version has these removed completely? We are using DHIS 2 Version:
> 2.25
> Build revision:
> a143100
> Build date:
> 2017-02-07 14:28
>
> If they have not been removed in 2.25, how can we delete them via the Web
> API?
>
> Thanks,
>
> Lorill
>
>
>
> * ERROR 2017-02-14 13:25:49,092 ERROR: update or delete on table
> "dataelement" violates foreign key constraint "fk_caseaggregationcondition_dataelement"
> on table "caseaggregationcondition"
> Detail: Key (dataelementid)=(109575) is still referenced from table
> "caseaggregationcondition". (SqlExceptionHelper.java [http-nio-8090-exec-8])
> org.hibernate.exception.ConstraintViolationException: could not execute
> statement
> at org.hibernate.exception.internal.SQLStateConversionDelegate.
> convert(SQLStateConversionDelegate.java:112)
> at org.hibernate.exception.internal.StandardSQLExceptionConvert
> er.convert(StandardSQLExceptionConverter.java:42)
> at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql
> ExceptionHelper.java:111)
> at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql
> ExceptionHelper.java:97)
> at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.execu
> teUpdate(ResultSetReturnImpl.java:207)
> at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.ad
> dToBatch(NonBatchingBatch.java:45)
> at org.hibernate.persister.entity.AbstractEntityPersister.delet
> e(AbstractEntityPersister.java:3233)
> at org.hibernate.persister.entity.AbstractEntityPersister.delet
> e(AbstractEntityPersister.java:3470)
> at org.hibernate.action.internal.EntityDeleteAction.execute(Ent
> ityDeleteAction.java:98)
> at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQu
> eue.java:560)
> at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQu
> eue.java:434)
> at org.hibernate.event.internal.AbstractFlushingEventListener.p
> erformExecutions(AbstractFlushingEventListener.java:337)
> at org.hibernate.event.internal.DefaultFlushEventListener.onFlu
> sh(DefaultFlushEventListener.java:39)
> at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)
> at org.hisp.dhis.dxf2.metadata.objectbundle.DefaultObjectBundle
> Service.commit(DefaultObjectBundleService.java:158)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.springframework.aop.support.AopUtils.invokeJoinpointUsin
> gReflection(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.TransactionInter
> ceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
> at org.springframework.transaction.interceptor.TransactionAspec
> tSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
> at org.springframework.transaction.interceptor.TransactionInter
> ceptor.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.$Proxy186.commit(Unknown Source)
> at org.hisp.dhis.dxf2.metadata.DefaultMetadataImportService.imp
> ortMetadata(DefaultMetadataImportService.java:126)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.springframework.aop.support.AopUtils.invokeJoinpointUsin
> gReflection(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.TransactionInter
> ceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
> at org.springframework.transaction.interceptor.TransactionAspec
> tSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
> at org.springframework.transaction.interceptor.TransactionInter
> ceptor.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.$Proxy188.importMetadata(Unknown Source)
> at org.hisp.dhis.webapi.controller.AbstractCrudController.delet
> eObject(AbstractCrudController.java:772)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
> ssorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
> thodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:483)
> at org.springframework.web.method.support.InvocableHandlerMetho
> d.doInvoke(InvocableHandlerMethod.java:221)
> at org.springframework.web.method.support.InvocableHandlerMetho
> d.invokeForRequest(InvocableHandlerMethod.java:136)
> at org.springframework.web.servlet.mvc.method.annotation.Servle
> tInvocableHandlerMethod.invokeAndHandle(ServletInvocableHand
> lerMethod.java:110)
> at org.springframework.web.servlet.mvc.method.annotation.Reques
> tMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHan
> dlerAdapter.java:817)
> at org.springframework.web.servlet.mvc.method.annotation.Reques
> tMappingHandlerAdapter.handleInternal(RequestMappingHandlerA
> dapter.java:731)
> at org.springframework.web.servlet.mvc.method.AbstractHandlerMe
> thodAdapter.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.processRequ
> est(FrameworkServlet.java:968)
> at org.springframework.web.servlet.FrameworkServlet.doDelete(Fr
> ameworkServlet.java:892)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:654)
> at org.springframework.web.servlet.FrameworkServlet.service(Fra
> meworkServlet.java:844)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:291)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:239)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:330)
> at org.springframework.security.web.access.intercept.FilterSecu
> rityInterceptor.invoke(FilterSecurityInterceptor.java:118)
> at org.springframework.security.web.access.intercept.FilterSecu
> rityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.access.ExceptionTranslation
> Filter.doFilter(ExceptionTranslationFilter.java:113)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.session.SessionManagementFi
> lter.doFilter(SessionManagementFilter.java:103)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.authentication.AnonymousAut
> henticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.servletapi.SecurityContextH
> olderAwareRequestFilter.doFilter(SecurityContextHolderAwareR
> equestFilter.java:154)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.savedrequest.RequestCacheAw
> areFilter.doFilter(RequestCacheAwareFilter.java:45)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.authentication.www.BasicAut
> henticationFilter.doFilter(BasicAuthenticationFilter.java:201)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.hisp.dhis.security.filter.CorsFilter.doFilter(CorsFilter.java:91)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.authentication.AbstractAuth
> enticationProcessingFilter.doFilter(AbstractAuthenticationPr
> ocessingFilter.java:199)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.authentication.AbstractAuth
> enticationProcessingFilter.doFilter(AbstractAuthenticationPr
> ocessingFilter.java:199)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.hisp.dhis.security.filter.CustomAuthenticationFilter.doF
> ilter(CustomAuthenticationFilter.java:64)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.oauth2.provider.authentication.
> OAuth2AuthenticationProcessingFilter.doFilter(OAuth2Authenti
> cationProcessingFilter.java:140)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.authentication.logout.Logou
> tFilter.doFilter(LogoutFilter.java:110)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.hisp.dhis.security.filter.AutomaticAccessFilter.doFilter
> (AutomaticAccessFilter.java:115)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.header.HeaderWriterFilter.d
> oFilterInternal(HeaderWriterFilter.java:57)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter
> (OncePerRequestFilter.java:107)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.context.request.async.WebAs
> yncManagerIntegrationFilter.doFilterInternal(WebAsyncManager
> IntegrationFilter.java:50)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter
> (OncePerRequestFilter.java:107)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.context.SecurityContextPers
> istenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
> at org.springframework.security.web.FilterChainProxy$VirtualFil
> terChain.doFilter(FilterChainProxy.java:342)
> at org.springframework.security.web.FilterChainProxy.doFilterIn
> ternal(FilterChainProxy.java:192)
> at org.springframework.security.web.FilterChainProxy.doFilter(F
> ilterChainProxy.java:160)
> at org.springframework.web.filter.DelegatingFilterProxy.invokeD
> elegate(DelegatingFilterProxy.java:346)
> at org.springframework.web.filter.DelegatingFilterProxy.doFilte
> r(DelegatingFilterProxy.java:262)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:239)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.hisp.dhis.servlet.filter.HttpUrlPatternFilter.doFilter(H
> ttpUrlPatternFilter.java:105)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:239)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.springframework.web.filter.ShallowEtagHeaderFilter.doFil
> terInternal(ShallowEtagHeaderFilter.java:87)
> at org.hisp.dhis.servlet.filter.ExcludableShallowEtagHeaderFilt
> er.doFilterInternal(ExcludableShallowEtagHeaderFilter.java:110)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter
> (OncePerRequestFilter.java:107)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:239)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.springframework.orm.hibernate5.support.OpenSessionInView
> Filter.doFilterInternal(OpenSessionInViewFilter.java:151)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter
> (OncePerRequestFilter.java:107)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:239)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.springframework.web.filter.CharacterEncodingFilter.doFil
> terInternal(CharacterEncodingFilter.java:121)
> at org.springframework.web.filter.OncePerRequestFilter.doFilter
> (OncePerRequestFilter.java:107)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFi
> lter(ApplicationFilterChain.java:239)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(App
> licationFilterChain.java:206)
> at org.apache.catalina.core.StandardWrapperValve.invoke(Standar
> dWrapperValve.java:219)
> at org.apache.catalina.core.StandardContextValve.invoke(Standar
> dContextValve.java:106)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(A
> uthenticatorBase.java:502)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHo
> stValve.java:142)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo
> rtValve.java:79)
> at org.apache.catalina.valves.AbstractAccessLogValve.invoke(Abs
> tractAccessLogValve.java:610)
> at org.apache.catalina.core.StandardEngineValve.invoke(Standard
> EngineValve.java:88)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAd
> apter.java:518)
> at org.apache.coyote.http11.AbstractHttp11Processor.process(Abs
> tractHttp11Processor.java:1091)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler
> .process(AbstractProtocol.java:668)
> at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionH
> andler.process(Http11NioProtocol.java:223)
> at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun
> (NioEndpoint.java:1517)
> at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(N
> ioEndpoint.java:1474)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
> Executor.java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
> lExecutor.java:617)
> at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.r
> un(TaskThread.java:61)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on
> table "dataelement" violates foreign key constraint
> "fk_caseaggregationcondition_dataelement" on table
> "caseaggregationcondition"
> Detail: Key (dataelementid)=(109575) is still referenced from table
> "caseaggregationcondition".
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorRespons
> e(QueryExecutorImpl.java:2455)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(Quer
> yExecutorImpl.java:2155)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecut
> orImpl.java:288)
> at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
> at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
> at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgP
> reparedStatement.java:168)
> at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPrep
> aredStatement.java:135)
> at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUp
> date(NewProxyPreparedStatement.java:105)
> at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.execu
> teUpdate(ResultSetReturnImpl.java:204)
> ... 137 more
>
>
>
> On Tue, Dec 13, 2016 at 1:13 AM, Lars Helge Øverland <lars@xxxxxxxxx>
> wrote:
>
>> Hi Channara,
>>
>> that means that the delete was not allowed due to case aggregation
>> conditions still referencing the data element. You need to the delete the
>> case aggregation queries first. If you upgrade to a later version of DHIS
>> 2, those have been removed completely.
>>
>> regards,
>>
>> Lars
>>
>> On Tue, Dec 13, 2016 at 9:50 AM, channara rin <rin.channara@xxxxxxxxx>
>> wrote:
>>
>>> dear all,
>>> i want to delete in data elements. but when i click remove, i got
>>> console like below:
>>> * INFO 2016-12-13 15:48:27,917 Delete was not allowed by
>>> CaseAggregationConditionDeletionHandler: CaseAggregationCondition
>>> (DefaultDeletionManager.java [http-nio-80-exec-8])
>>>
>>> do you know this problem, how can i delete it?
>>>
>>> thank you
>>> channara
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-users
>>> Post to : dhis2-users@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-users
>>> More help : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> Lars Helge Øverland
>> Lead developer, DHIS 2
>> University of Oslo
>> Skype: larshelgeoverland
>> lars@xxxxxxxxx
>> http://www.dhis2.org <https://www.dhis2.org/>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Lorill Crees
> Project Leader / Senior Developer
> 2Paths Solutions Ltd. <http://www.2paths.com>
>
> lcrees@xxxxxxxxxx
> skype: lorill2paths
> (604) 689-4123 x 15 <(604)%20689-4123>
>
--
Lars Helge Øverland
Lead developer, DHIS 2
University of Oslo
Skype: larshelgeoverland
lars@xxxxxxxxx
http://www.dhis2.org <https://www.dhis2.org/>
Follow ups
References