Community
Participate
Working Groups
In (Helios based) SAP NWDS I add an implementation of PropertyChangeListener to an attribute like this: --------------------------------------------- JavaPerisistentAttribute jpa = ...; .... PropertyChangeListener lsnr = new PropertyChangeListenerImpl(); JavaAttributeMapping jam = jpa.getMapping(); if ((jam == null) || !RelationshipMapping.class. isInstance(jam)) return; RelationshipReference rr = ((RelationshipMapping) jam). getRelationshipReference(); JoiningStrategy js = rr.getPredominantJoiningStrategy(); if ((js == null) || !MappedByJoiningStrategy. class.isInstance(js)) return; js.addPropertyChangeListener(MappedByJoiningStrategy. MAPPED_BY_ATTRIBUTE_PROPERTY, lsnr); --------------------------------------------- and it seems that the execution of the following code: --------------------------------------------- JavaPerisistentAttribute jpa = ...; ........... JavaAttributeMapping mapping = jpa.getMapping(); if (OwnableRelationshipMappingAnnotation.class. isInstance(mapping.getMappingAnnotation())) { ((OwnableRelationshipMappingAnnotation)mapping. getMappingAnnotation()). setMappedBy(<some string>); --------------------------------------------- is not detected by the listener. When I manually change the value of the mappedBy of the following attribute of the entity it's detected by the listener. Is it a bug or am I doing something wrong? (It was working with Galileo)
What you are seeing is the beginning of work to clean up our interaction with the JDT model. Brian is currently working on this in bug 233567. In Helios he made a change that means changes to the java resource model do not fire change events that would cause the context model to update. After the resource model change you can call JpaProject.synchronizeContextModel() to cause the context model to update. This is what we do in tests where we are looking for changes to the resource model to be propagated to the context model. getMappingAnnotation().setMappedBy(<some string>); getJpaProject().synchronizeContextModel(); Your other possibility is to modify the context model directly (I'm avoiding instanceof checks for simplicity): JavaRelationshipMapping relationshipMapping = jpa.getMapping(); OwnableRelationshipReference ownableRef = relationshipMapping.getRelationshipReference(); if (!ownableRef.usesMappedByJoiningStrategy()) { ownableRef.setMappedByJoiningStrategy(); } ownableRef.getMappedByJoiningStrategy().setMappedByAttribute(<some string>);
Yes, this helped. 10x.