Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357691

Summary: issue with removing a container annotation and it still exists in our model
Product: [WebTools] Dali JPA Tools Reporter: Karen Butzke <karenfbutzke>
Component: JPAAssignee: Karen Butzke <karenfbutzke>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: 3.1 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Karen Butzke CLA 2011-09-14 17:00:12 EDT
I have a specific use case with the new eclipselink multitenant support, but this is a general problem in the 3.1 release.

1. Create a JPA 2.0 project with the EclipseLInik 2.3.x platform.
2. Create an entity:
@Entity
@TenantDiscriminatorColumns(@TenantDiscriminatorColumn(name="TENANT_ID"))
public class Foo {
    @Id int id;
}
3. Validate and you will see the warning "Tenant discriminator columns cannot be specified without the Multitenant annotation"
4. Remove the outer annotation @TenantDiscriminatorColumns and save and validate again. The warning does not appear again and if you look in the error log you will see an exception:

java.lang.IllegalArgumentException: Null text range for message ID: MULTIENANT_NOT_SPECIFIED_WITH_TENANT_DISCRIMINATOR_COLUMNS
	at org.eclipse.jpt.jpa.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages.buildMessage(DefaultEclipseLinkJpaValidationMessages.java:48)
	at org.eclipse.jpt.jpa.eclipselink.core.internal.v2_3.context.java.JavaEclipseLinkMultitenancyImpl.validate(JavaEclipseLinkMultitenancyImpl.java:394)


Our resource model is still holding on to the TenantDiscriminatorColumns annotation object even though it has been removed. That is the underlying cause of this particular exception. This could cause other difficult to diagnose problems as well. If you clean the project, the validation message appears correctly.
Comment 1 Karen Butzke CLA 2011-09-16 16:46:34 EDT
Another container annotation issue was found by Nan in bug 357941. Will address this in this bug.

If you have a java 1-1 mapping with a JoinTable on it and try to change the mapping type in the JPA structure or Details view to 1-many you get an exception:

java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(AbstractList.java:350)
	at org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator.nestedNext(CloneListIterator.java:177)
	at org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator.next(CloneListIterator.java:112)
	at org.eclipse.jpt.common.core.internal.resource.java.source.SourceMember.setPrimaryAnnotation(SourceMember.java:95)
	at org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentAttribute.setMappingAnnotation(AbstractJavaPersistentAttribute.java:291)
Comment 2 Karen Butzke CLA 2011-09-19 12:18:31 EDT
I can reproduce the issue in comment 1 if I set the strategy to pk join columns, then mappedBy, then change the mapping type to 1-m.
Comment 3 Karen Butzke CLA 2011-09-20 10:49:48 EDT
fixed for M2