Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 190910 Details for
Bug 325162
[Validation] Embeddable class contained within an element collection must not a contain an element collection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch with additional recommended changes
propossed_patch_325162_2.txt (text/plain), 17.66 KB, created by
Leslie Davis
on 2011-03-10 14:50:57 EST
(
hide
)
Description:
patch with additional recommended changes
Filename:
MIME Type:
Creator:
Leslie Davis
Created:
2011-03-10 14:50:57 EST
Size:
17.66 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jpt.jpa.core >Index: property_files/jpa_validation.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_validation.properties,v >retrieving revision 1.5 >diff -u -r1.5 jpa_validation.properties >--- property_files/jpa_validation.properties 3 Mar 2011 00:01:17 -0000 1.5 >+++ property_files/jpa_validation.properties 10 Mar 2011 19:48:25 -0000 >@@ -185,6 +185,8 @@ > VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED=In implied attribute \"{0}\", map key class is not defined > ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE=Target class \"{0}\" is not an embeddable or basic type > VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE=In implied attribute \"{0}\" target class \"{1}\" is not an embeddable or basic type >+ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_ELEMENT_COLLECTION_MAPPING=Mapping contains an embeddable \"{0}\" which contains an element collection mapping, element collections may not contain embeddables with element collection mappings. >+ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING=Mapping contains an embeddable \"{0}\" which contains a prohibited entity relationship mapping. Embeddables in element collections may only contain many-to-one or one-to-one mappings and be on the \"owning\" side of the relationship. > MAP_KEY_COLUMN_UNRESOLVED_NAME = Map key column \"{0}\" cannot be resolved on table \"{1}\" > VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_UNRESOLVED_NAME = In implied attribute \"{0}\", map key column \"{1}\" cannot be resolved on table \"{2}\" > COLLECTION_TABLE_UNRESOLVED_CATALOG = Catalog \"{0}\" cannot be resolved for collection table \"{1}\" >Index: src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java,v >retrieving revision 1.4 >diff -u -r1.4 AbstractJavaElementCollectionMapping2_0.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java 24 Feb 2011 22:37:26 -0000 1.4 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java 10 Mar 2011 19:48:25 -0000 >@@ -29,12 +29,14 @@ > import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator; > import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; > import org.eclipse.jpt.jpa.core.JpaFactory; >+import org.eclipse.jpt.jpa.core.MappingKeys; > import org.eclipse.jpt.jpa.core.context.AssociationOverride; > import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; > import org.eclipse.jpt.jpa.core.context.AttributeMapping; > import org.eclipse.jpt.jpa.core.context.AttributeOverride; > import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; > import org.eclipse.jpt.jpa.core.context.BaseColumn; >+import org.eclipse.jpt.jpa.core.context.BaseEmbeddedMapping; > import org.eclipse.jpt.jpa.core.context.Column; > import org.eclipse.jpt.jpa.core.context.Converter; > import org.eclipse.jpt.jpa.core.context.Embeddable; >@@ -47,6 +49,7 @@ > import org.eclipse.jpt.jpa.core.context.Override_; > import org.eclipse.jpt.jpa.core.context.PersistentType; > import org.eclipse.jpt.jpa.core.context.Relationship; >+import org.eclipse.jpt.jpa.core.context.RelationshipMapping; > import org.eclipse.jpt.jpa.core.context.Table; > import org.eclipse.jpt.jpa.core.context.TypeMapping; > import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverrideContainer; >@@ -1156,6 +1159,96 @@ > this.collectionTable.validate(messages, reporter, astRoot); > this.validateValue(messages, reporter, astRoot); > this.validateMapKey(messages, reporter, astRoot); >+ this.validateNoEmbeddableInMappingContainsProhibittedMapping(messages, astRoot); >+ } >+ >+ protected void validateNoEmbeddableInMappingContainsProhibittedMapping(List<IMessage> messages, CompilationUnit astRoot) { >+ Embeddable embeddableClass = getResolvedTargetEmbeddable(); >+ if (embeddableClass != null) { >+ embeddableContainsElementCollection(messages, astRoot, embeddableClass); >+ embeddableContainsProhibitedRelationshipMapping(messages, astRoot, embeddableClass); >+ embeddableHierarchyContainsProhibittedMapping(messages, astRoot, embeddableClass, new ArrayList<Embeddable>()); >+ } >+ embeddableClass = getResolvedMapKeyEmbeddable(); >+ if (embeddableClass != null) { >+ embeddableContainsElementCollection(messages, astRoot, embeddableClass); >+ embeddableContainsProhibitedRelationshipMapping(messages, astRoot, embeddableClass); >+ embeddableHierarchyContainsProhibittedMapping(messages, astRoot, embeddableClass, new ArrayList<Embeddable>()); >+ } >+ } >+ >+ private void embeddableHierarchyContainsProhibittedMapping(List<IMessage> messages, CompilationUnit astRoot, Embeddable parentEmbeddable, List<Embeddable> visited) { >+ Iterable<AttributeMapping> embeddedIterable = parentEmbeddable.getAllAttributeMappings(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); >+ for(AttributeMapping mapping : embeddedIterable) { >+ Embeddable embeddable = ((BaseEmbeddedMapping)mapping).getTargetEmbeddable(); >+ if (embeddable != null && embeddable != parentEmbeddable) { >+ embeddableContainsElementCollection(messages, astRoot, embeddable); >+ embeddableContainsProhibitedRelationshipMapping(messages, astRoot, embeddable); >+ if (!CollectionTools.contains(visited, embeddable)) { >+ visited.add(embeddable); >+ embeddableHierarchyContainsProhibittedMapping(messages, astRoot, embeddable, visited); >+ } >+ } >+ } >+ Iterable<AttributeMapping> embeddedIdIterable = parentEmbeddable.getAllAttributeMappings(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); >+ for(AttributeMapping mapping : embeddedIdIterable) { >+ Embeddable embeddable = ((BaseEmbeddedMapping)mapping).getTargetEmbeddable(); >+ if (embeddable != null && embeddable != parentEmbeddable) { >+ embeddableContainsElementCollection(messages, astRoot, embeddable); >+ embeddableContainsProhibitedRelationshipMapping(messages, astRoot, embeddable); >+ if (!CollectionTools.contains(visited, embeddable)) { >+ visited.add(embeddable); >+ embeddableHierarchyContainsProhibittedMapping(messages, astRoot, embeddable, visited); >+ } >+ } >+ } >+ } >+ >+ private void embeddableContainsProhibitedRelationshipMapping(List<IMessage> messages, CompilationUnit astRoot, Embeddable embeddable) { >+ boolean prohibitedMappingFound = false; >+ Iterable<AttributeMapping> manyToManyMappings = embeddable.getAllAttributeMappings(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); >+ Iterable<AttributeMapping> oneToManyMappings = embeddable.getAllAttributeMappings(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); >+ if (oneToManyMappings.iterator().hasNext() || manyToManyMappings.iterator().hasNext()) { >+ prohibitedMappingFound = true; >+ } >+ Iterable<AttributeMapping> manyToOneMappings = embeddable.getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); >+ if (manyToOneMappings.iterator().hasNext()) { >+ if (((RelationshipMapping)manyToOneMappings.iterator().next()).getRelationshipOwner() != null) { >+ prohibitedMappingFound = true; >+ } >+ } >+ Iterable<AttributeMapping> oneToOneMappings = embeddable.getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); >+ if (oneToOneMappings.iterator().hasNext()) { >+ if (((RelationshipMapping)oneToOneMappings.iterator().next()).getRelationshipOwner() != null) { >+ prohibitedMappingFound = true; >+ } >+ } >+ if (prohibitedMappingFound) { >+ messages.add( >+ DefaultJpaValidationMessages.buildMessage( >+ IMessage.HIGH_SEVERITY, >+ JpaValidationMessages.ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING, >+ new String[] {embeddable.getName()}, >+ this, >+ this.getValidationTextRange(astRoot) >+ ) >+ ); >+ } >+ } >+ >+ private void embeddableContainsElementCollection(List<IMessage> messages, CompilationUnit astRoot, Embeddable embeddable) { >+ Iterable<AttributeMapping> elementCollectionMappings = embeddable.getAllAttributeMappings(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); >+ if (elementCollectionMappings.iterator().hasNext()) { >+ messages.add( >+ DefaultJpaValidationMessages.buildMessage( >+ IMessage.HIGH_SEVERITY, >+ JpaValidationMessages.ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_ELEMENT_COLLECTION_MAPPING, >+ new String[] {embeddable.getName()}, >+ this, >+ this.getValidationTextRange(astRoot) >+ ) >+ ); >+ } > } > > protected void validateTargetClass(List<IMessage> messages, CompilationUnit astRoot) { >Index: src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java,v >retrieving revision 1.4 >diff -u -r1.4 AbstractOrmElementCollectionMapping2_0.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java 24 Feb 2011 22:37:26 -0000 1.4 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java 10 Mar 2011 19:48:25 -0000 >@@ -12,6 +12,7 @@ > import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; >+ > import org.eclipse.emf.common.util.EList; > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IPackageFragment; >@@ -29,12 +30,14 @@ > import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator; > import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator; > import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; >+import org.eclipse.jpt.jpa.core.MappingKeys; > import org.eclipse.jpt.jpa.core.context.AssociationOverride; > import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; > import org.eclipse.jpt.jpa.core.context.AttributeMapping; > import org.eclipse.jpt.jpa.core.context.AttributeOverride; > import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; > import org.eclipse.jpt.jpa.core.context.BaseColumn; >+import org.eclipse.jpt.jpa.core.context.BaseEmbeddedMapping; > import org.eclipse.jpt.jpa.core.context.Column; > import org.eclipse.jpt.jpa.core.context.Converter; > import org.eclipse.jpt.jpa.core.context.Embeddable; >@@ -47,6 +50,7 @@ > import org.eclipse.jpt.jpa.core.context.Override_; > import org.eclipse.jpt.jpa.core.context.PersistentType; > import org.eclipse.jpt.jpa.core.context.Relationship; >+import org.eclipse.jpt.jpa.core.context.RelationshipMapping; > import org.eclipse.jpt.jpa.core.context.Table; > import org.eclipse.jpt.jpa.core.context.TypeMapping; > import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride; >@@ -1214,6 +1218,96 @@ > this.collectionTable.validate(messages, reporter); > this.validateValue(messages, reporter); > this.validateMapKey(messages, reporter); >+ this.validateNoEmbeddableInMappingContainsProhibittedMapping(messages); >+ } >+ >+ protected void validateNoEmbeddableInMappingContainsProhibittedMapping(List<IMessage> messages) { >+ Embeddable embeddableClass = getResolvedTargetEmbeddable(); >+ if (embeddableClass != null) { >+ embeddableContainsElementCollection(messages, embeddableClass); >+ embeddableContainsProhibitedRelationshipMapping(messages, embeddableClass); >+ embeddableHierarchyContainsProhibittedMapping(messages, embeddableClass, new ArrayList<Embeddable>()); >+ } >+ embeddableClass = getResolvedMapKeyEmbeddable(); >+ if (embeddableClass != null) { >+ embeddableContainsElementCollection(messages, embeddableClass); >+ embeddableContainsProhibitedRelationshipMapping(messages, embeddableClass); >+ embeddableHierarchyContainsProhibittedMapping(messages, embeddableClass, new ArrayList<Embeddable>()); >+ } >+ } >+ >+ private void embeddableHierarchyContainsProhibittedMapping(List<IMessage> messages, Embeddable parentEmbeddable, List<Embeddable> visited) { >+ Iterable<AttributeMapping> embeddedIterable = parentEmbeddable.getAllAttributeMappings(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); >+ for(AttributeMapping mapping : embeddedIterable) { >+ Embeddable embeddable = ((BaseEmbeddedMapping)mapping).getTargetEmbeddable(); >+ if (embeddable != null && embeddable != parentEmbeddable) { >+ embeddableContainsElementCollection(messages, embeddable); >+ embeddableContainsProhibitedRelationshipMapping(messages, embeddable); >+ if (!CollectionTools.contains(visited, embeddable)) { >+ visited.add(embeddable); >+ embeddableHierarchyContainsProhibittedMapping(messages, embeddable, visited); >+ } >+ } >+ } >+ Iterable<AttributeMapping> embeddedIdIterable = parentEmbeddable.getAllAttributeMappings(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); >+ for(AttributeMapping mapping : embeddedIdIterable) { >+ Embeddable embeddable = ((BaseEmbeddedMapping)mapping).getTargetEmbeddable(); >+ if (embeddable != null && embeddable != parentEmbeddable) { >+ embeddableContainsElementCollection(messages, embeddable); >+ embeddableContainsProhibitedRelationshipMapping(messages, embeddable); >+ if (!CollectionTools.contains(visited, embeddable)) { >+ visited.add(embeddable); >+ embeddableHierarchyContainsProhibittedMapping(messages, embeddable, visited); >+ } >+ } >+ } >+ } >+ >+ private void embeddableContainsProhibitedRelationshipMapping(List<IMessage> messages, Embeddable embeddable) { >+ boolean prohibitedMappingFound = false; >+ Iterable<AttributeMapping> manyToManyMappings = embeddable.getAllAttributeMappings(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); >+ Iterable<AttributeMapping> oneToManyMappings = embeddable.getAllAttributeMappings(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); >+ if (oneToManyMappings.iterator().hasNext() || manyToManyMappings.iterator().hasNext()) { >+ prohibitedMappingFound = true; >+ } >+ Iterable<AttributeMapping> manyToOneMappings = embeddable.getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); >+ if (manyToOneMappings.iterator().hasNext()) { >+ if (((RelationshipMapping)manyToOneMappings.iterator().next()).getRelationshipOwner() != null) { >+ prohibitedMappingFound = true; >+ } >+ } >+ Iterable<AttributeMapping> oneToOneMappings = embeddable.getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); >+ if (oneToOneMappings.iterator().hasNext()) { >+ if (((RelationshipMapping)oneToOneMappings.iterator().next()).getRelationshipOwner() != null) { >+ prohibitedMappingFound = true; >+ } >+ } >+ if (prohibitedMappingFound) { >+ messages.add( >+ DefaultJpaValidationMessages.buildMessage( >+ IMessage.HIGH_SEVERITY, >+ JpaValidationMessages.ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING, >+ new String[] {embeddable.getName()}, >+ this, >+ this.getValidationTextRange() >+ ) >+ ); >+ } >+ } >+ >+ private void embeddableContainsElementCollection(List<IMessage> messages, Embeddable embeddable) { >+ Iterable<AttributeMapping> elementCollectionMappings = embeddable.getAllAttributeMappings(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY); >+ if (elementCollectionMappings.iterator().hasNext()) { >+ messages.add( >+ DefaultJpaValidationMessages.buildMessage( >+ IMessage.HIGH_SEVERITY, >+ JpaValidationMessages.ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_ELEMENT_COLLECTION_MAPPING, >+ new String[] {embeddable.getName()}, >+ this, >+ this.getValidationTextRange() >+ ) >+ ); >+ } > } > > protected void validateTargetClass(List<IMessage> messages) { >Index: src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 JpaValidationMessages.java >--- src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java 3 Mar 2011 00:01:17 -0000 1.4 >+++ src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java 10 Mar 2011 19:48:25 -0000 >@@ -207,6 +207,8 @@ > public static final String ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED = "ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED"; > public static final String ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED = "ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED"; > public static final String ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST = "ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST"; >+ public static final String ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_ELEMENT_COLLECTION_MAPPING = "ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_ELEMENT_COLLECTION_MAPPING"; >+ public static final String ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING = "ELEMENT_COLLECTION_CONTAINS_EMBEDDABLE_WITH_PROHIBITED_RELATIONSHIP_MAPPING"; > public static final String VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST = "VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST"; > public static final String VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED = "VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED"; > public static final String ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED = "ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED";
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 325162
:
190194
|
190850
|
190910
|
191033
|
211360
|
211374