Hi,
  Looks like a potential issue. 

  Please 
  1. create a JIRA issue
  2. two patches : one for a test case and one with your suggested fix
  3. submit the patch with the JIRA issue (do not forget to grant access --
last radio button on "Attach Patch" page in JIRA)

  I will review and apply the patch if necessary.


  Thanks --

   

ashishpaliwal wrote:
> 
> Hi,
> 
> I had two entities, Person and Address with @OneToOne mapping. I wanted to
> have a custom mapping for address data, so gave
> @strategy(somepackage.MyStrategy) in getAddress() method in Person.java.
> The
> MyStrategy class was extending from RelationFieldStrategy class and I
> overrode load() method. But, I saw that my strategy was never called. I
> debugged and observed few things:
> AnnotationPersistenceMappingParser was correctly parsing my @strategy
> annotation in parseMemberMappingAnnotation() method and was executing case
> Strat: setting strategy for ValueMappingInfo object. When execution came
> to
> RuntimeStrategyInstaller.installStrategy() method, in the very first line
> it
> was fetching strategy from FieldMappingInfo , not from ValueMappingInfo in
> which AnnotationPersistenceMappingParser.parseMemberMappingAnnotation()
> method had set the strategy. It ultimetely fetched the default strategy
> RelationFieldStrategy.
> When I changed the parseMemberMappingAnnotation()  method in case Strat: i
> wrote fm.getMappingInfo().setStrategy(((Strategy) anno).value()) , which
> basically stores strategy in FieldMappingInfo rather than in
> ValueMappingInfo. Now everything ran smoothly and myStrategy was called.
> 
> I wanted to know where am I making mistake that my strategy is not being
> called without making the change that I have made. I have gone through the
> docs as well as some examples from the web, but to no help.
> 
> Offcourse there is another method of injecting my strategy, that of
> extending PersistenceMappingDefaults and then overriding getStrategy()
> method such that it calls myStrategy for Person.Address. Also entry of
> overriden class has to be entered in persistence.xml. This I tried and
> everything worked. But certainly, this is less user friendly for user than
> to just write the @annotation tag over address field.
> 
> Any help is greatly appreciated.
> 
> thanks and regards
> 
> 
> -- 
> Ashish Paliwal
> Mobile : 9305128367
> IIT Kanpur
> India
> 
> 


-----
Pinaki Poddar                      http://ppoddar.blogspot.com/
                                      
http://www.linkedin.com/in/pinakipoddar
OpenJPA PMC Member/Committer
JPA Expert Group Member
-- 
View this message in context: 
http://n2.nabble.com/Problem-with-%40strategy-tp2997709p3006993.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to