Community
Participate
Working Groups
>The following line should only process ManagedType types (which does not include BasicType). QueryBuilderImpl:51 public <T> CriteriaQuery<T> createQuery(Class<T> resultClass){ ... ManagedType type = this.metamodel.type(resultClass); >see the API function /** * Return the metamodel managed type representing the * entity, mapped superclass, or embeddable class. * @param clazz the type of the represented managed class * @return the metamodel managed type * @throws IllegalArgumentException if not a managed class */ public <X> ManagedType<X> type(Class<X> clazz) >IAE exception handlers for MetamodelImpl are disabled until this fix is in.
>See the following tests (1 normal, 2 variant (null, BasicType) that expect a managedType, IAE and IAE respectively in MetamodelMetamodelTest:1507 // test normal path: (subtype = MappedSuperclass) expectedIAExceptionThrown = false; try { Type<Person> aType = metamodel.type(Person.class); } catch (IllegalArgumentException iae) { iae.printStackTrace(); expectedIAExceptionThrown = true; } assertFalse(expectedIAExceptionThrown); // test variant path: null causes IAE expectedIAExceptionThrown = false; try { Type<?> aType = metamodel.type(null); } catch (IllegalArgumentException iae) { //iae.printStackTrace(); expectedIAExceptionThrown = true; } assertTrue(expectedIAExceptionThrown); // test variant path: wrong type (java simple type) expectedIAExceptionThrown = false; try { Type<?> aType = metamodel.embeddable(Integer.class); } catch (IllegalArgumentException iae) { //iae.printStackTrace(); expectedIAExceptionThrown = true; } assertTrue(expectedIAExceptionThrown);
Created attachment 143398 [details] MetamodelImpl.type() handler for null type return (handles both Clazz not found and Basic type lookup) >Handle a null (not found) return differently from a Basic Type return (IAE) >test results TEST MODEL NAME: (JUnit test): Criteria Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 26 Total Tests: 26 TEST MODEL NAME: (JUnit test): MetamodelTestSuite Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 3 Total Tests: 3
>see rev# 4779 http://fisheye2.atlassian.com/changelog/eclipselink/?cs=4779 Test results (JPA LRG): normal, null and IAE paths in MetamodelMetamodelTest:1504 (with 2 known failures fixed) [junit] Tests run: 1300, Failures: 0, Errors: 0, Time elapsed: 1,467.537 sec
Mass update to change fixed in target.
>Note: The function name has changed in the final PFD for the Type interface From public <X> ManagedType<X> type(Class<X> clazz) To public <X> ManagedType<X> managedType(Class<X> clazz)
>During a pass through the code - I have decided that the specification is clear - all non-ManagedType clazz parameters should throw an IAE - even null. The function needs to be reverted back to it's original state - not that it has been renamed .managedType() and its' usage in the Criteria tests should be modified to getType(). I discussed this with Chris.
>There is a secondary issue to the fix. In the ''Metamodel'' interface there is no specification function that will return a ''Type'' - the implementation classes will need to be used in this case. >see reopened design issue 54 http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_54:_20090803:_Metamodel.type.28Clazz.29_should_differentiate_between_null_and_BasicType CriteriaQueryImpl.java:118 public CriteriaQuery<T> select(Selection<? extends T> selection) { // From: ManagedType type = this.metamodel.managedType(this.queryType); // To: TypeImpl type = ((MetamodelImpl)this.metamodel).getType(this.queryType); >Test results >With Metamodel change and no Metamodel-test/Criteria-impl change TEST MODEL NAME: (JUnit test): test_MetamodelFullImplementation(org.eclipse.persistence.testing.tests.jpa.metamodel.MetamodelMetamodelTest) Errors: (failures): 1 Fatal Errors: (errors): 0 Passed: 0 Total Tests: 1 TEST NAME: test_MetamodelFullImplementation(org.eclipse.persistence.testing.tests.jpa.metamodel.MetamodelMetamodelTest) RESULT: Error (failure) junit.framework.AssertionFailedError: IllegalArgumentException not expected on Metamodel.managedType(Integer.class) at junit.framework.Assert.fail(Assert.java:47) TEST MODEL NAME: (JUnit test): Criteria Errors: (failures): 0 Fatal Errors: (errors): 15 Passed: 104 Total Tests: 119 >With Metamodel change and one of the Criteria changes (fixes 12 of the 15 issues) TEST MODEL NAME: (JUnit test): Criteria Errors: (failures): 0 Fatal Errors: (errors): 3 Passed: 116 Total Tests: 119
Created attachment 149571 [details] Failures that are fixed by the attached patch for any call to .managedType() where we expect a BasicType back - used to return null - now throws an IAE by spec.
Created attachment 149572 [details] DI 54: Metamodel/Criteria Impl change: throw IAE on any Metamodel.managedType(clazz) call where clazz is wrapped by a BasicType - used to return null - use MetamodelImpl.getType(clazz) instead
>test results with patch change on 5536 TEST MODEL NAME: (JUnit test): Criteria Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 119 Total Tests: 119 TEST MODEL NAME: (JUnit test): Metamodel Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 10 Total Tests: 10
>In review
>Reviewed by Gordon - see SVN rev# 5540 http://fisheye2.atlassian.com/changelog/eclipselink/?cs=5540 Test results (JPA LRG) off 5536 [junit] Tests run: 1423, Failures: 0, Errors: 0, Time elapsed: 1,162.806 sec
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink