Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveObjects - deleting

b
Contributor
April 3, 2012

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);
}

2 answers

1 accepted

1 vote
Answer accepted
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2012

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 ...).

0 votes
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2012

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).

b
Contributor
April 4, 2012

OK, I've put User model. I still don't know what is wrong

Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2012

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).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events