Hi,
I have to following error:
java.sql.SQLException: Integrity constraint violation FK_AO_AD8E0F_USER_MAIL_TEMPLATE_ENTITY_ID table: AO_AD8E0F_USER in statement [DELETE FROM PUBLIC.AO_AD8E0F_MAIL_TEMPLATE WHERE ID IN (?)] at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.delete(EntityManagedActiveObjects.java:117) at com.atlassian.activeobjects.osgi.DelegatingActiveObjects.delete(DelegatingActiveObjects.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58) at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56) at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy1405.delete(Unknown Source) at MyServiceImpl.deleteById(MailTemplateServiceImpl.java:102)
The error is suggesting that there's trouble with foreign key.Here's my models
@Preload public interface MailTemplate extends Entity { @OneToMany public IssueRole[] getIssueRoles();
@OneToMany public User[] getUsers(); } @Preload public interface IssueRole extends Entity { public MailTemplate getMailTemplateEntity(); public void setMailTemplateEntity(MailTemplate mailTemplateEntity); }
Any suggestion?
--------------------------------------------
UPDATE
@Preload public interface User extends Entity { @NotNull public String getName(); public void setName(String name); public MailTemplate getMailTemplate(); public void setMailTemplate(MailTemplate mailTemplate); }
Uh, well, as per error, you have a reference in the User model to MailTemplate. Understand the dependencies, implement your own custom delete method, work at the outside references and move in, or perhaps more usefully, provide error messages to the user indicating they have dependencies to resolve (can't delete because ...).
The FK error indicates there is FK contraint from the USER table, preventing the deletion of your Template object. I suspect you have a trailing reference in USER (given its not posted).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Look at the content of the tables. You should find the User table holds a reference to your MailTemplate. You can't delete a MailTemplate whilst there is relationship with another table, you'll have to clear the MailTemplate reference from the User table before you can delete the MailTemplate. Or as I suggested, inform the user that the link exists, and implement functionality to allow the user to do something about it (like remote the association, however your plugin works).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.