Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319561 - Attribute predominant joining strategy listener doesn't work well
Summary: Attribute predominant joining strategy listener doesn't work well
Status: CLOSED INVALID
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: Framework (show other bugs)
Version: 2.3   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: dali.framework-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-12 09:40 EDT by Stefan Dimov CLA
Modified: 2010-07-14 11:41 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Dimov CLA 2010-07-12 09:40:40 EDT
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)
Comment 1 Karen Butzke CLA 2010-07-13 10:57:19 EDT
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>);
Comment 2 Stefan Dimov CLA 2010-07-14 11:41:41 EDT
Yes, this helped. 10x.