public void testUpdateSpecifiedSchema() throws Exception { createTestEntityWithElementCollection(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().getAttributes().iterator().next().getMapping(); CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable(); JavaResourceType resourceType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME, AstNodeType.TYPE); JavaResourceField resourceField = resourceType.getFields().iterator().next(); CollectionTableAnnotation2_0 resourceCollectionTable = (CollectionTableAnnotation2_0) resourceField.getAnnotation(CollectionTableAnnotation2_0.ANNOTATION_NAME); assertNull(collectionTable.getSpecifiedSchema()); assertNull(resourceCollectionTable); // set schema in the resource model, verify context model updated resourceField.addAnnotation(CollectionTableAnnotation2_0.ANNOTATION_NAME); resourceCollectionTable = (CollectionTableAnnotation2_0) resourceField.getAnnotation(CollectionTableAnnotation2_0.ANNOTATION_NAME); resourceCollectionTable.setSchema("FOO"); getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedSchema()); assertEquals("FOO", resourceCollectionTable.getSchema()); // set schema to null in the resource model resourceCollectionTable.setSchema(null); getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedSchema()); assertNull(resourceCollectionTable.getSchema()); resourceCollectionTable.setSchema("FOO"); getJpaProject().synchronizeContextModel(); assertEquals("FOO", collectionTable.getSpecifiedSchema()); assertEquals("FOO", resourceCollectionTable.getSchema()); resourceField.removeAnnotation(CollectionTableAnnotation2_0.ANNOTATION_NAME); getJpaProject().synchronizeContextModel(); assertNull(collectionTable.getSpecifiedSchema()); assertNull(resourceField.getAnnotation(CollectionTableAnnotation2_0.ANNOTATION_NAME)); }