我的数据库中有两个表:一个用于持久化用户,另一个用于保存他们的权限。
问题是,当我尝试删除用户时,必须删除权限,这样我就可以避免收到违反约束的异常。我使用JPAcascadeType.ALL和孤儿删除=true:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "users",cascade = CascadeType.ALL,orphanRemoval = true)
public Set<Authorities> getAuthoritieses() {
return this.authoritieses;
}
问题是,只有在将要删除的用户是在另一个会话中创建的情况下,hibernate才会生成对权限的删除查询:当我创建用户时,添加一些权限,然后尝试删除它,会引发违反限制的例外情况,而在另一会话中创建用户时则不是这种情况(然后,hibernate会生成对权限进行删除的查询)。
这是引发的异常(这里的“notification_config”是指用户的自动表和“liste_envoi”):
sept. 07, 2015 7:42:14 AM com.sun.faces.lifecycle.InvokeApplicationPhase execute
Avertissement: #{listeEnvoiBean.suppListe()}: org.springframework.dao.DataIntegrityViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
javax.faces.FacesException: #{listeEnvoiBean.suppListe()}: org.springframework.dao.DataIntegrityViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:71)
at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:64)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:654)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:64)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
Caused by: javax.faces.el.EvaluationException: org.springframework.dao.DataIntegrityViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 66 more
Caused by: org.springframework.dao.DataIntegrityViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:163)
at org.springframework.orm.hibernate4.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:730)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:592)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:521)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
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:207)
at com.sun.proxy.$Proxy49.supprimer(Unknown Source)
at controller.reporting.ListeEnvoiBean.suppListe(ListeEnvoiBean.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 67 more
Caused by: org.hibernate.exception.ConstraintViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
at org.hibernate.exception.internal.SQLStateConverter.convert(SQLStateConverter.java:104)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy77.executeUpdate(Unknown Source)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:56)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3124)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3327)
at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:91)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:265)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:191)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:323)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
... 84 more
Caused by: org.postgresql.util.PSQLException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:321)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 100 more
javax.faces.FacesException: #{listeEnvoiBean.suppListe()}: org.springframework.dao.DataIntegrityViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: ERREUR: UPDATE ou DELETE sur la table « liste_envoi » viole la contrainte de clé étrangère
« notifconfiglistefk » de la table « notification_config »
Détail : La clé (id)=(5) est toujours référencée à partir de la table « notification_config ».
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:654)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:64)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
任何帮助都将不胜感激..
我通过移除cascadeType解决了这个问题。ALL,并在所有外键约束中在数据库级别设置它。
根据 JPA 标准的要求,如果 PERSIST
操作应用/级联到已删除的实体,Hibernate 将取消计划删除。
确保从所有其他托管实体实例中删除对要删除的实体的所有引用。
可能发生的情况是,某些引用授权
的实体在删除不起作用的会话中加载,但在删除按预期工作的会话中未加载(因此PERSIST
未级联)。
项目使用 Hibernate 3.5、Spring Webflow 2 和 Hibernate Envers 进行审计。Envers 配置为Hibernate.cfg.xml。我在实体“文章组”和“文章”之间有一对多的关系映射。表“文章”具有外键“article_group_id”引用表“article_groups”中的 id。在前端,当我删除文章时,Hibernate Envers 会为删除后
问题内容: 我想使用外键来保持完整性并避免使用孤立键(我已经使用过innoDB)。 如何创建在CASCADE上删除的SQL语句? 如果我删除一个类别,那么如何确保它不会删除也与其他类别相关的产品。 数据透视表“ categories_products”在其他两个表之间创建多对多关系。 问题答案: 如果您的级联删除某个产品是因为该产品属于被杀类别的成员,那么它会删除该产品,那么您的外键设置不正确。给
问题内容: 我有以下示例: 我想在级联排如果双方并从各自的表被删除。 删除两个外键后,如何在表C中级联自身? 如果仅删除一个FK,则受影响的行应在引用该外键的列中更改为空值。 问题答案: 我建议使用两个外键约束和一个触发器来处理其余的 表格: 扳机: SQL提琴。 确保连接表具有替代PK列。无论如何都不能是PK,因为那将不允许两者都为NULL。而是添加一个约束,该约束允许使用NULL值。 触发器针
问题内容: 我在使用JPA / Hibernate(3.5.3)设置时遇到麻烦,在这里我有一个实体,即“ Account”类,该类具有子实体列表,“ Contact”实例。我试图能够将Contact的实例添加/删除到Account的List 属性中。 将新实例添加到集合中并调用saveOrUpdate(account)可以保留所有可爱的东西。如果我然后选择从列表中删除该联系人并再次调用saveOr
我见过其他的链接错误,但没有一个能说明如何使用罐子。当我在Jboss中部署我的应用程序时,它可以正常工作,但当我将应用程序部署到websphere时,我遇到了这种链接错误。在这里可以找到一个类似的问题:调用webservice方法时出现LinkageError,但不确定如何修复它 它主要是从和加载的,带有共享类 我所拥有的是jsp调用Web服务。从消息中,我看到的唯一jars来自axis.jar,
我在WebSphereApplicationServer(8.5.5.14)中遇到了LinkageError。这里也发现了类似的问题LinkageError 原因:java。lang.LinkageError:解析方法“javax/xml/soap/SOAPElement.getElementQName()Ljavax/xml/namespace/QName;”时加载约束冲突:loader“com