This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
View | Details | Raw Unified | Return to bug 266912 | Differences between
and this patch

Collapse All | Expand All

(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/metamodel/MetamodelMetamodelTest.java (-7 / +8 lines)
Lines 1498-1514 Link Here
1498
            }
1498
            }
1499
            assertFalse(expectedIAExceptionThrown);            
1499
            assertFalse(expectedIAExceptionThrown);            
1500
1500
1501
            // 20090803: 2 tests below commented until bug# 285512 is fixed
1501
            // test variant path: null does not cause an IAE in this case because its return type cannot be checked for isManagedType
1502
/*            
1502
            expectedIAExceptionThrown = false;
1503
            // test variant path: null causes IAE
1503
            // Set type to a temporary type - to verify that we get null and not confuse a return of null with an "unset" null.
1504
            expectedIAExceptionThrown = false;            
1504
            Type<?> aTypeFromNullClass = metamodel.type(Manufacturer.class);
1505
            try {
1505
            try {
1506
                Type<?> aType = metamodel.type(null);
1506
                aTypeFromNullClass = metamodel.type(null);
1507
            } catch (IllegalArgumentException iae) {
1507
            } catch (IllegalArgumentException iae) {
1508
                //iae.printStackTrace();
1508
                //iae.printStackTrace();
1509
                expectedIAExceptionThrown = true;            
1509
                expectedIAExceptionThrown = true;            
1510
            }
1510
            }
1511
            assertTrue(expectedIAExceptionThrown);            
1511
            assertNull(aTypeFromNullClass);
1512
            assertFalse(expectedIAExceptionThrown);            
1512
1513
1513
            // test variant path: wrong type (java simple type)
1514
            // test variant path: wrong type (java simple type)
1514
            expectedIAExceptionThrown = false;            
1515
            expectedIAExceptionThrown = false;            
Lines 1521-1527 Link Here
1521
            assertTrue(expectedIAExceptionThrown);            
1522
            assertTrue(expectedIAExceptionThrown);            
1522
1523
1523
            // test variant path: wrong type (BasicType)
1524
            // test variant path: wrong type (BasicType)
1524
*/
1525
1525
            /**
1526
            /**
1526
             *  Return the metamodel embeddable type representing the
1527
             *  Return the metamodel embeddable type representing the
1527
             *  embeddable class.
1528
             *  embeddable class.
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metamodel/MetamodelImpl.java (-11 / +16 lines)
Lines 72-81 Link Here
72
    /** The Map of embeddables in this metamodel keyed on Class **/
72
    /** The Map of embeddables in this metamodel keyed on Class **/
73
    protected Map<Class, EmbeddableTypeImpl<?>> embeddables;
73
    protected Map<Class, EmbeddableTypeImpl<?>> embeddables;
74
74
75
    /** The Map of managed types in this metamodel keyed on Class **/
75
    /** The Map of managed types (Entity, Embeddable and MappedSuperclass) in this metamodel keyed on Class **/
76
    protected Map<Class, ManagedTypeImpl<?>> managedTypes;
76
    protected Map<Class, ManagedTypeImpl<?>> managedTypes;
77
    
77
    
78
    /** The Map of types in this metamodel keyed on Class **/
78
    /** The Map of types (Entity, Embeddable, MappedSuperclass and Basic - essentially Basic + managedTypes) in this metamodel keyed on Class **/
79
    private Map<Class, TypeImpl<?>> types;
79
    private Map<Class, TypeImpl<?>> types;
80
80
81
    /** The Set of MappedSuperclassTypes in this metamodel**/
81
    /** The Set of MappedSuperclassTypes in this metamodel**/
Lines 313-327 Link Here
313
     */
313
     */
314
    public <X> ManagedType<X> type(Class<X> clazz) {
314
    public <X> ManagedType<X> type(Class<X> clazz) {
315
        Object aType = this.managedTypes.get(clazz);
315
        Object aType = this.managedTypes.get(clazz);
316
        return (ManagedType<X>)aType;
316
        // Throw an IAE exception if the returned type is not a ManagedType
317
        // IAE exception is disabled until bug# 285512 is fixed
317
        // However in this case the type will usually be null - as no Basic types are in the managedTypes Map
318
/*        if(aType instanceof ManagedType) {
318
        if(null == aType) {
319
            return (ManagedType<X>) this.managedTypes.get(clazz);
319
            // return null as there is no way to check the return type for isManagedType
320
        } else {
320
            return null;
321
            throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
321
        } else {        
322
                    "metamodel_class_incorrect_type_instance", 
322
            if(aType instanceof ManagedType) {
323
                    new Object[] { clazz, "ManagedType", aType}));
323
                return (ManagedType<X>) this.managedTypes.get(clazz);
324
        }*/
324
            } else {
325
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
326
                        "metamodel_class_incorrect_type_instance", 
327
                        new Object[] { clazz, "ManagedType", aType}));
328
            }
329
        }
325
    }
330
    }
326
    
331
    
327
    /**
332
    /**
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/querydef/QueryBuilderImpl.java (-1 / +1 lines)
Lines 59-65 Link Here
59
            ManagedType type = this.metamodel.type(resultClass);
59
            ManagedType type = this.metamodel.type(resultClass);
60
            if (type != null && type.getPersistenceType().equals(PersistenceType.ENTITY)){
60
            if (type != null && type.getPersistenceType().equals(PersistenceType.ENTITY)){
61
                return new CriteriaQueryImpl(this.metamodel, ResultType.ENTITY, resultClass , this);
61
                return new CriteriaQueryImpl(this.metamodel, ResultType.ENTITY, resultClass , this);
62
            }else {
62
            } else {
63
                return new CriteriaQueryImpl(this.metamodel, ResultType.OTHER, resultClass, this);
63
                return new CriteriaQueryImpl(this.metamodel, ResultType.OTHER, resultClass, this);
64
            }
64
            }
65
        }
65
        }

Return to bug 266912