|
Lines 37-42
Link Here
|
| 37 |
import javax.persistence.metamodel.ListAttribute; |
37 |
import javax.persistence.metamodel.ListAttribute; |
| 38 |
import javax.persistence.metamodel.ManagedType; |
38 |
import javax.persistence.metamodel.ManagedType; |
| 39 |
import javax.persistence.metamodel.MapAttribute; |
39 |
import javax.persistence.metamodel.MapAttribute; |
|
|
40 |
import javax.persistence.metamodel.MappedSuperclassType; |
| 40 |
import javax.persistence.metamodel.Metamodel; |
41 |
import javax.persistence.metamodel.Metamodel; |
| 41 |
import javax.persistence.metamodel.PluralAttribute; |
42 |
import javax.persistence.metamodel.PluralAttribute; |
| 42 |
import javax.persistence.metamodel.SetAttribute; |
43 |
import javax.persistence.metamodel.SetAttribute; |
|
Lines 71-76
Link Here
|
| 71 |
import org.eclipse.persistence.testing.models.jpa.metamodel.EnclosureIdClassPK; |
72 |
import org.eclipse.persistence.testing.models.jpa.metamodel.EnclosureIdClassPK; |
| 72 |
import org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition; |
73 |
import org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition; |
| 73 |
import org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner; |
74 |
import org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner; |
|
|
75 |
import org.eclipse.persistence.testing.models.jpa.metamodel.MS_MS_Entity_Center; |
| 76 |
import org.eclipse.persistence.testing.models.jpa.metamodel.MS_MS_Entity_Leaf; |
| 77 |
import org.eclipse.persistence.testing.models.jpa.metamodel.MS_MS_Entity_Root; |
| 74 |
import org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer; |
78 |
import org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer; |
| 75 |
import org.eclipse.persistence.testing.models.jpa.metamodel.Memory; |
79 |
import org.eclipse.persistence.testing.models.jpa.metamodel.Memory; |
| 76 |
import org.eclipse.persistence.testing.models.jpa.metamodel.Person; |
80 |
import org.eclipse.persistence.testing.models.jpa.metamodel.Person; |
|
Lines 152-157
Link Here
|
| 152 |
suite.addTest(new MetamodelMetamodelTest("testEntityType")); |
156 |
suite.addTest(new MetamodelMetamodelTest("testEntityType")); |
| 153 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getIdType_Method")); |
157 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getIdType_Method")); |
| 154 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getIdClassAttributes_Method")); |
158 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getIdClassAttributes_Method")); |
|
|
159 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getIdClassAttributesAcrossMappedSuperclassChain_Method")); // 288792 |
| 155 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_hasVersionAttribute_Method")); |
160 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_hasVersionAttribute_Method")); |
| 156 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_hasSingleIdAttribute_Method")); |
161 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_hasSingleIdAttribute_Method")); |
| 157 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getSupertype_Method")); |
162 |
suite.addTest(new MetamodelMetamodelTest("testIdentifiableType_getSupertype_Method")); |
|
Lines 295-301
Link Here
|
| 295 |
|
300 |
|
| 296 |
private void privateTestTeardown() { |
301 |
private void privateTestTeardown() { |
| 297 |
} |
302 |
} |
|
|
303 |
|
| 298 |
|
304 |
|
|
|
305 |
/* public void testValidation_relaxed_for_composite_pk_on_mappedSuperclass_chain() { |
| 306 |
if(!this.isJPA10()) { |
| 307 |
EntityManager em = null; |
| 308 |
boolean exceptionThrown = false; |
| 309 |
try { |
| 310 |
em = privateTestSetup(); |
| 311 |
assertNotNull(em); |
| 312 |
Metamodel metamodel = em.getMetamodel(); |
| 313 |
assertNotNull("The metamodel should never be null after an em.getMetamodel() call here.", metamodel); |
| 314 |
ManagedType<Person> msPerson = metamodel.managedType(Person.class); |
| 315 |
assertNotNull(msPerson); |
| 316 |
assertEquals(Type.PersistenceType.MAPPED_SUPERCLASS, msPerson.getPersistenceType()); |
| 317 |
} catch (IllegalArgumentException iae) { |
| 318 |
//iae.printStackTrace(); |
| 319 |
exceptionThrown = true; |
| 320 |
} finally { |
| 321 |
cleanup(em); |
| 322 |
assertFalse("An IAE exception should not occur here.", exceptionThrown); |
| 323 |
} |
| 324 |
} |
| 325 |
}*/ |
| 326 |
|
| 327 |
|
| 299 |
// http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_93:_20091014:_Single_PK_support_in_IdentifiableTypeImpl.getIdType.28.29_does_not_fully_handle_a_null_CMPPolicy_on_the_Descriptor |
328 |
// http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_93:_20091014:_Single_PK_support_in_IdentifiableTypeImpl.getIdType.28.29_does_not_fully_handle_a_null_CMPPolicy_on_the_Descriptor |
| 300 |
public void testIdentifiableType_getIdType_handles_possible_null_cmppolicy() { |
329 |
public void testIdentifiableType_getIdType_handles_possible_null_cmppolicy() { |
| 301 |
if(!this.isJPA10()) { |
330 |
if(!this.isJPA10()) { |
|
Lines 1775-1786
Link Here
|
| 1775 |
// We verify that an @IdClass exists - no single @Id or @EmbeddedId exists |
1804 |
// We verify that an @IdClass exists - no single @Id or @EmbeddedId exists |
| 1776 |
assertFalse(hasSingleIdAttribute); |
1805 |
assertFalse(hasSingleIdAttribute); |
| 1777 |
idClassAttributes = aType.getIdClassAttributes(); |
1806 |
idClassAttributes = aType.getIdClassAttributes(); |
| 1778 |
assertFalse(expectedIAExceptionThrown); |
|
|
| 1779 |
assertFalse(hasSingleIdAttribute); |
| 1780 |
assertNotNull(idClassAttributes); |
1807 |
assertNotNull(idClassAttributes); |
| 1781 |
assertEquals(4, idClassAttributes.size()); |
1808 |
assertEquals(4, idClassAttributes.size()); |
| 1782 |
} catch (IllegalArgumentException iae) { |
1809 |
} catch (IllegalArgumentException iae) { |
| 1783 |
//iae.printStackTrace(); |
1810 |
iae.printStackTrace(); |
| 1784 |
expectedIAExceptionThrown = true; |
1811 |
expectedIAExceptionThrown = true; |
| 1785 |
} finally { |
1812 |
} finally { |
| 1786 |
cleanup(em); |
1813 |
cleanup(em); |
|
Lines 1789-1794
Link Here
|
| 1789 |
} |
1816 |
} |
| 1790 |
} |
1817 |
} |
| 1791 |
|
1818 |
|
|
|
1819 |
public void testIdentifiableType_getIdClassAttributesAcrossMappedSuperclassChain_Method() { |
| 1820 |
if(!this.isJPA10()) { |
| 1821 |
EntityManager em = null; |
| 1822 |
boolean expectedIAExceptionThrown = false; |
| 1823 |
try { |
| 1824 |
em = privateTestSetup(); |
| 1825 |
assertNotNull(em); |
| 1826 |
Metamodel metamodel = em.getMetamodel(); |
| 1827 |
assertNotNull(metamodel); |
| 1828 |
|
| 1829 |
// Actual Test Case |
| 1830 |
/** |
| 1831 |
* Return the attributes corresponding to the id class of the |
| 1832 |
* identifiable type. |
| 1833 |
* @return id attributes |
| 1834 |
* @throws IllegalArgumentException if the identifiable type |
| 1835 |
* does not have an id class |
| 1836 |
*/ |
| 1837 |
//java.util.Set<SingularAttribute<? super X, ?>> getIdClassAttributes(); |
| 1838 |
// @IdClass - test normal path |
| 1839 |
expectedIAExceptionThrown = false; |
| 1840 |
boolean hasSingleIdAttribute = true; |
| 1841 |
// 0 id attributes here |
| 1842 |
Set<SingularAttribute<? super MS_MS_Entity_Leaf, ?>> idClassAttributesLeaf = null; |
| 1843 |
IdentifiableType<MS_MS_Entity_Leaf> aTypeLeaf = metamodel.entity(MS_MS_Entity_Leaf.class); |
| 1844 |
// 1 id attribute here |
| 1845 |
Set<SingularAttribute<? super MS_MS_Entity_Center, ?>> idClassAttributesCenter = null; |
| 1846 |
MappedSuperclassType<MS_MS_Entity_Center> aTypeCenter = (MappedSuperclassType)metamodel.managedType(MS_MS_Entity_Center.class); |
| 1847 |
// 3 id attributes here |
| 1848 |
Set<SingularAttribute<? super MS_MS_Entity_Root, ?>> idClassAttributesRoot = null; |
| 1849 |
MappedSuperclassType<MS_MS_Entity_Root> aTypeRoot = (MappedSuperclassType)metamodel.managedType(MS_MS_Entity_Root.class); |
| 1850 |
|
| 1851 |
hasSingleIdAttribute = aTypeLeaf.hasSingleIdAttribute(); |
| 1852 |
// We verify that an an @IdClass exists above |
| 1853 |
assertFalse(hasSingleIdAttribute); // This tests the IdentifiableType part of the transaction for DI 78 |
| 1854 |
hasSingleIdAttribute = aTypeCenter.hasSingleIdAttribute(); |
| 1855 |
// We verify that an one part of an @IdClass exists |
| 1856 |
assertTrue(hasSingleIdAttribute); // This tests the IdentifiableType part of the transaction for DI 78 |
| 1857 |
hasSingleIdAttribute = aTypeRoot.hasSingleIdAttribute(); |
| 1858 |
// We verify that an @IdClass exists - no single @Id or @EmbeddedId exists |
| 1859 |
assertFalse(hasSingleIdAttribute); // This tests the IdentifiableType part of the transaction for DI 78 |
| 1860 |
//idClassAttributesLeaf = aTypeLeaf.getIdClassAttributes(); // expected IAE |
| 1861 |
idClassAttributesCenter = aTypeCenter.getIdClassAttributes(); |
| 1862 |
assertNotNull(idClassAttributesCenter); |
| 1863 |
assertEquals(1, idClassAttributesCenter.size()); |
| 1864 |
// The following call is not valid because the IdClass attribute is defined one level below |
| 1865 |
try { |
| 1866 |
idClassAttributesRoot = aTypeRoot.getIdClassAttributes(); |
| 1867 |
} catch (IllegalArgumentException iae) { |
| 1868 |
expectedIAExceptionThrown = true; |
| 1869 |
} |
| 1870 |
assertTrue(expectedIAExceptionThrown); |
| 1871 |
expectedIAExceptionThrown = false; |
| 1872 |
} catch (IllegalArgumentException iae) { |
| 1873 |
iae.printStackTrace(); |
| 1874 |
expectedIAExceptionThrown = true; |
| 1875 |
} finally { |
| 1876 |
cleanup(em); |
| 1877 |
assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown); |
| 1878 |
} |
| 1879 |
} |
| 1880 |
} |
| 1881 |
|
| 1792 |
public void testIdentifiableType_getIdType_Method() { |
1882 |
public void testIdentifiableType_getIdType_Method() { |
| 1793 |
if(!this.isJPA10()) { |
1883 |
if(!this.isJPA10()) { |
| 1794 |
EntityManager em = null; |
1884 |
EntityManager em = null; |