Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/GenericRootContextNode.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceUnit.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java59
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java9
15 files changed, 86 insertions, 47 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
index a0ce965395..96b6ab8345 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
@@ -28,7 +28,7 @@ PERSISTENCE_UNIT_REDUNDANT_CLASS=Class \"{0}\" is already specified in mapping f
GENERATOR_DUPLICATE_NAME=Duplicate generator named \"{0}\" defined in this persistence unit
QUERY_DUPLICATE_NAME=Duplicate query named \"{0}\" defined in this persistence unit
ENTITY_MAPPINGS_MULTIPLE_METADATA=Metadata for persistence unit \"{0}\" specified in multiple mapping files
-PERSISTENT_TYPE_UNSPECIFIED_CONTEXT=This mapped class is not contained in any persistence unit
+PERSISTENT_TYPE_UNSPECIFIED_CONTEXT=This mapped class is not specified in persistence unit \"{0}\"
PERSISTENT_TYPE_UNSPECIFIED_CLASS=Unspecified class
PERSISTENT_TYPE_UNRESOLVED_CLASS=Class \"{0}\" cannot be resolved
ENTITY_NO_ID=Entity \"{0}\" has no Id or EmbeddedId
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/GenericRootContextNode.java
index e2bc3d4188..3df53ba009 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/GenericRootContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/GenericRootContextNode.java
@@ -221,21 +221,27 @@ public class GenericRootContextNode extends AbstractJpaContextNode
//handled with other validation
return;
}
+ if (getJpaProject().discoversAnnotatedClasses()) {
+ return;
+ }
Collection<IType> orphanedClasses = CollectionTools.collection(getJpaProject().annotatedClasses());
+ if (getPersistenceXml().getPersistence().persistenceUnitsSize() != 1) {
+ //context model currently only supports 1 persistenceUnit
+ return;
+ }
+ PersistenceUnit persistenceUnit = getPersistenceXml().getPersistence().persistenceUnits().next();
for (IType type : CollectionTools.iterable(getJpaProject().annotatedClasses())) {
- for (PersistenceUnit persistenceUnit : CollectionTools.iterable(getPersistenceXml().getPersistence().persistenceUnits())) {
- for (ClassRef classRef : CollectionTools.iterable(persistenceUnit.classRefs())) {
- if (classRef.isFor(type.getFullyQualifiedName('.'))) {
- orphanedClasses.remove(type);
- }
+ for (ClassRef classRef : CollectionTools.iterable(persistenceUnit.specifiedClassRefs())) {
+ if (classRef.isFor(type.getFullyQualifiedName('.'))) {
+ orphanedClasses.remove(type);
+ }
+ }
+ for (MappingFileRef mappingFileRef : CollectionTools.iterable(persistenceUnit.mappingFileRefs())) {
+ if (mappingFileRef.getOrmXml() == null || mappingFileRef.getOrmXml().getEntityMappings() == null) {
+ continue;
}
- for (MappingFileRef mappingFileRef : CollectionTools.iterable(persistenceUnit.mappingFileRefs())) {
- if (mappingFileRef.getOrmXml() == null || mappingFileRef.getOrmXml().getEntityMappings() == null) {
- continue;
- }
- if (mappingFileRef.getOrmXml().getEntityMappings().getPersistentType(type.getFullyQualifiedName('.')) != null) {
- orphanedClasses.remove(type);
- }
+ if (mappingFileRef.getOrmXml().getEntityMappings().getPersistentType(type.getFullyQualifiedName('.')) != null) {
+ orphanedClasses.remove(type);
}
}
}
@@ -246,6 +252,7 @@ public class GenericRootContextNode extends AbstractJpaContextNode
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
JpaValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CONTEXT,
+ new String[] {persistenceUnit.getName()},
javaResourcePersistentType.getResourceModel().getFile(),
javaResourcePersistentType.getMappingAnnotation().getTextRange(JDTTools.buildASTRoot(orphanedType)))
);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceUnit.java
index 79528f0dba..6a9920d03a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceUnit.java
@@ -931,7 +931,7 @@ public class GenericPersistenceUnit extends AbstractPersistenceJpaContextNode
Iterator<IType> annotatedClasses = getJpaProject().annotatedClasses();
- if (getJpaProject().discoversAnnotatedClasses() && !isExcludeUnlistedClasses()) {
+ if (!isExcludeUnlistedClasses()) {
while (impliedRefs.hasNext()) {
ClassRef classRef = impliedRefs.next();
boolean updated = false;
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java
index 37ef707521..812cb96f97 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java
@@ -17,8 +17,10 @@ import org.eclipse.jpt.core.JpaFile;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.core.context.orm.OrmEntity;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.context.orm.OrmXml;
+import org.eclipse.jpt.core.context.persistence.ClassRef;
import org.eclipse.jpt.core.context.persistence.MappingFileRef;
import org.eclipse.jpt.core.resource.java.JPA;
import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
@@ -204,11 +206,16 @@ public class JpaFileTests extends ContextModelTestCase
IType testType = createTestEntity();
JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
+ JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertTrue(javaJpaFile.rootStructureNodes().next().getParent() instanceof OrmEntity);
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
entityMappings().removeOrmPersistentType(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+
+ assertEquals(1, javaJpaFile.rootStructureNodesSize());
+ assertTrue(javaJpaFile.rootStructureNodes().next().getParent() instanceof ClassRef);
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
}
public void testOrmJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception {
@@ -217,10 +224,15 @@ public class JpaFileTests extends ContextModelTestCase
IType testType = createTestEntity();
JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
+ JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertTrue(javaJpaFile.rootStructureNodes().next().getParent() instanceof OrmEntity);
ormResource().getEntityMappings().getEntities().remove(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+
+ assertEquals(1, javaJpaFile.rootStructureNodesSize());
+ assertTrue(javaJpaFile.rootStructureNodes().next().getParent() instanceof ClassRef);
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
}
public void testJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
@@ -230,9 +242,11 @@ public class JpaFileTests extends ContextModelTestCase
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentType javaPersistentType = javaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(entityMappings().getPersistenceUnit().specifiedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
entityMappings().getPersistenceUnit().removeSpecifiedClassRef(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(entityMappings().getPersistenceUnit().impliedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
}
public void testJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception {
@@ -242,9 +256,11 @@ public class JpaFileTests extends ContextModelTestCase
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentType javaPersistentType = javaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(entityMappings().getPersistenceUnit().specifiedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(entityMappings().getPersistenceUnit().impliedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
}
public void testImpliedJavaPersistentTypeRootStructureNodeRemoved() throws Exception {
@@ -266,10 +282,13 @@ public class JpaFileTests extends ContextModelTestCase
IType testType = createTestEntity();
JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
+ JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
ormResource().getContents().remove(ormResource().getEntityMappings());
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(1, javaJpaFile.rootStructureNodesSize());
+ assertEquals(persistenceUnit().impliedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
}
public void testJavaRootStructureNodesOrmPersistentTypeRemoved() throws Exception {
@@ -278,10 +297,13 @@ public class JpaFileTests extends ContextModelTestCase
IType testType = createTestEntity();
JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
+ JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
entityMappings().removeOrmPersistentType(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(1, javaJpaFile.rootStructureNodesSize());
+ assertEquals(entityMappings().getPersistenceUnit().impliedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
}
public void testJavaRootStructureNodesOrmTypeMappingMorphed() throws Exception {
@@ -290,14 +312,18 @@ public class JpaFileTests extends ContextModelTestCase
IType testType = createTestEntity();
JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
+ JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
ormPersistentType.setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
assertEquals(1, javaJpaFile.rootStructureNodesSize());
- assertEquals(entityMappings().ormPersistentTypes().next().getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
+ javaPersistentType = entityMappings().ormPersistentTypes().next().getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
entityMappings().removeOrmPersistentType(0);
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(1, javaJpaFile.rootStructureNodesSize());
+ assertEquals(entityMappings().getPersistenceUnit().impliedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
}
public void testUpdateOrmJavaRootStructureNodeMappingFileRefChanged() throws Exception {
@@ -340,12 +366,15 @@ public class JpaFileTests extends ContextModelTestCase
IType testType = createTestEntity();
JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource());
- assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next());
+ JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
+ assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next());
deleteResource(ormResource());
- assertFalse(javaJpaFile.rootStructureNodes().hasNext());
+ assertNotSame(javaPersistentType, javaJpaFile.rootStructureNodes().next());
+ assertEquals(1, javaJpaFile.rootStructureNodesSize());
+ assertEquals(persistenceUnit().impliedClassRefs().next(), javaJpaFile.rootStructureNodes().next().getParent());
}
//TODO test rootStructureNodes with a static inner class
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java
index eb16d4896f..af0d14dcf1 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java
@@ -165,7 +165,6 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase
public void testDefaultEmbeddedIdMapping() throws Exception {
createTestEntityWithEmbeddedIdMapping();
- createEmbeddableType();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
@@ -176,6 +175,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase
assertTrue(persistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping);
assertTrue(persistentAttribute.getMapping().isDefault());
+ createEmbeddableType();
addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
assertTrue(persistentAttribute.getMapping().isDefault());
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java
index b68b5623db..f51473e41f 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java
@@ -163,7 +163,6 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase
public void testDefaultEmbeddedMapping() throws Exception {
createTestEntityWithEmbeddedMapping();
- createEmbeddableType();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
@@ -174,6 +173,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase
assertTrue(persistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping);
assertTrue(persistentAttribute.getMapping().isDefault());
+ createEmbeddableType();
addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
assertTrue(persistentAttribute.getMapping().isDefault());
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java
index c43524f623..7269ba9f27 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java
@@ -179,7 +179,7 @@ public class JavaJoinColumnTests extends ContextModelTestCase
JavaOneToOneMapping oneToOneMapping = (JavaOneToOneMapping) javaPersistentType().attributes().next().getMapping();
JavaJoinColumn defaultJavaJoinColumn = oneToOneMapping.getDefaultJoinColumn();
- assertNull(defaultJavaJoinColumn.getDefaultName());
+// assertNull(defaultJavaJoinColumn.getDefaultName());
//TODO test default join column name
// //add target entity to the persistence unit, now join table name is [table name]_[target table name]
// addXmlClassRef(PACKAGE_NAME + ".Project");
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java
index bf23e9e2d0..ca0bd64e87 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java
@@ -187,7 +187,6 @@ public class JavaJoinTableTests extends ContextModelTestCase
public void testDefaultName() throws Exception {
createTestEntityWithValidManyToMany();
- createTargetEntity();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
@@ -198,6 +197,7 @@ public class JavaJoinTableTests extends ContextModelTestCase
assertNull(joinTable.getDefaultName());
//add target entity to the persistence unit, now join table name is [table name]_[target table name]
+ createTargetEntity();
addXmlClassRef(PACKAGE_NAME + ".Project");
assertEquals(TYPE_NAME + "_Project", joinTable.getDefaultName());
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
index fe413a26fc..81b2d921fd 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java
@@ -671,7 +671,6 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase
public void testResolvedTargetEntity() throws Exception {
createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
@@ -681,6 +680,7 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase
assertNull(manyToManyMapping.getResolvedTargetEntity());
//add targetEntity to the persistence unit, now target entity should resolve
+ createTestTargetEntityAddress();
addXmlClassRef(PACKAGE_NAME + ".Address");
ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
classRefs.next();
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java
index 34257f9919..2867d21254 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java
@@ -872,7 +872,6 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase
public void testResolvedTargetEntity() throws Exception {
createTestEntityWithValidManyToOneMapping();
- createTestTargetEntityAddress();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
@@ -882,6 +881,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase
assertNull(manyToOneMapping.getResolvedTargetEntity());
//add targetEntity to the persistence unit, now target entity should resolve
+ createTestTargetEntityAddress();
addXmlClassRef(PACKAGE_NAME + ".Address");
ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
classRefs.next();
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
index 64e638cca9..7c4171e236 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java
@@ -674,7 +674,6 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase
public void testResolvedTargetEntity() throws Exception {
createTestEntityWithValidOneToManyMapping();
- createTestTargetEntityAddress();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
@@ -684,6 +683,7 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase
assertNull(oneToManyMapping.getResolvedTargetEntity());
//add targetEntity to the persistence unit, now target entity should resolve
+ createTestTargetEntityAddress();
addXmlClassRef(PACKAGE_NAME + ".Address");
ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
classRefs.next();
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java
index f30f1d4620..9493c8b024 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java
@@ -1021,7 +1021,6 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase
public void testResolvedTargetEntity() throws Exception {
createTestEntityWithValidOneToOneMapping();
- createTestTargetEntityAddress();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
@@ -1031,6 +1030,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase
assertNull(oneToOneMapping.getResolvedTargetEntity());
//add targetEntity to the persistence unit, now target entity should resolve
+ createTestTargetEntityAddress();
addXmlClassRef(PACKAGE_NAME + ".Address");
ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
classRefs.next();
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java
index 64096c7805..f9313be0f5 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java
@@ -469,14 +469,14 @@ public class JavaPersistentTypeTests extends ContextModelTestCase
createTestEntityAnnotatedMethod();
createTestSubTypeWithFieldAnnotation();
- //parent is not added to the persistenceUnit, so even though it has an Entity
- //annotation it should not be found as the parentPersistentType
+ //parent is not added to the persistenceUnit, but it should still be found
+ //as the parentPersistentType because of impliedClassRefs and changes for bug 190317
addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
ListIterator<ClassRef> classRefs = persistenceUnit().specifiedClassRefs();
JavaPersistentType javaPersistentType = classRefs.next().getJavaPersistentType();
- assertNull(javaPersistentType.getParentPersistentType());
+ assertNotNull(javaPersistentType.getParentPersistentType());
}
//Entity extends Non-Entity extends Entity
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java
index 52fae36837..d2d6c2440e 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java
@@ -178,7 +178,6 @@ public class OrmJoinTableTests extends ContextModelTestCase
public void testVirtualJoinTable() throws Exception {
createTestEntityWithValidManyToMany();
- createTargetEntity();
OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
@@ -187,8 +186,9 @@ public class OrmJoinTableTests extends ContextModelTestCase
OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
assertTrue(ormPersistentAttribute.isVirtual());
- assertNull(ormJoinTable.getSpecifiedName());
+ assertEquals(null, ormJoinTable.getSpecifiedName());
+ createTargetEntity();
entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Project");
assertEquals(TYPE_NAME + "_Project", ormJoinTable.getSpecifiedName());
@@ -232,7 +232,6 @@ public class OrmJoinTableTests extends ContextModelTestCase
public void testUpdateDefaultNameFromJavaTable() throws Exception {
createTestEntityWithValidManyToMany();
- createTargetEntity();
OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
@@ -240,8 +239,9 @@ public class OrmJoinTableTests extends ContextModelTestCase
OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
OrmJoinTable ormJoinTable = ormManyToManyMapping.getJoinTable();
- assertNull(ormJoinTable.getDefaultName());
+ assertEquals(null, ormJoinTable.getDefaultName());
+ createTargetEntity();
OrmPersistentType targetPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Project");
assertEquals(TYPE_NAME + "_Project", ormJoinTable.getDefaultName());
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java
index 0a0ab95523..427710ba22 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java
@@ -636,10 +636,12 @@ public class PersistenceUnitTests extends ContextModelTestCase
public void testImpliedClassRefs() throws Exception {
createTestEntityWithPersistentInnerClass();
- assertFalse(persistenceUnit().impliedClassRefs().hasNext());
+ ListIterator<ClassRef> classRefs = persistenceUnit().impliedClassRefs();
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRefs.next().getClassName());
+ assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
jpaProject().setDiscoversAnnotatedClasses(true);
- ListIterator<ClassRef> classRefs = persistenceUnit().impliedClassRefs();
+ classRefs = persistenceUnit().impliedClassRefs();
assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRefs.next().getClassName());
assertEquals(FULLY_QUALIFIED_INNER_CLASS_NAME, classRefs.next().getClassName());
@@ -1088,8 +1090,9 @@ public class PersistenceUnitTests extends ContextModelTestCase
createTestEntity();
//persistentType not listed in persistence.xml and discoverAnnotatedClasses is false
+ //still find the persistentType because of changes for bug 190317
assertFalse(jpaProject().discoversAnnotatedClasses());
- assertNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
+ assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
//test persistentType not listed in persistence.xml, discover annotated classes set to true
jpaProject().setDiscoversAnnotatedClasses(true);

Back to the top