[
https://issues.apache.org/jira/browse/OPENJPA-2522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14148441#comment-14148441
]
Atul Kshirsagar commented on OPENJPA-2522:
------------------------------------------
We are using spring data and don't have access to EntityManagerFactory to use
the workaround as indicated above. This has become a blocker issue for us. Is
there any other workaround, which we can use when using Spring Data?
> With L2 Cache turned ON newly persisted entity on inverse side of relation
> doesn't have FK populated on 'find'/'query'
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2522
> URL: https://issues.apache.org/jira/browse/OPENJPA-2522
> Project: OpenJPA
> Issue Type: Bug
> Components: datacache, jpa
> Affects Versions: 2.2.2, 2.3.0
> Environment: apache karaf 2.3.0, openjpa 2.2.2
> Reporter: Atul Kshirsagar
> Attachments: Address.java, Person.java, TestL2CacheLazyLoading.java,
> persistence.xml
>
>
> With l2 cache turned on (by setting "openjpa.DataCache" property to "true" in
> persistence.xml) we observed following behavior:
> Lets say we have model Person <-> Address(LAZY, owner). We create a new
> instance of Person and Address. Since Person is non-owing side of relation,
> we set Person instance in Address but don't set Address instance in Person.
> We then persist both Person and Address instance. Later when we query Person
> entity by using EntityManager.find method the returned instance of Person
> doesn't have Address field set. This field doesn't get set even if we query
> Address entity.
> It appears that Person entity that was created when we persisted gets cached
> and it doesn't get refreshed when we query for that instance.
> I have looked at defect https://issues.apache.org/jira/browse/OPENJPA-2285
> and applied that fix to open jpa 2.2.2 but I still see the same behavior. I
> did some debugging and found that PCDataImpl.isLoaded method always returns
> true for the 'address' field and hence it looks up in its internal "_data"
> object array for value, which has null for 'address' field. In effect the
> check of the loadedFieldsAfter and loadedFieldsBefore introduced in
> OPENJPA-2285 doesn't trigger and cache is never updated.
> I have verified that this is indeed a cache problem by evicting the "Person"
> class from datacache (using
> EntityManagerFactory.getCache().evict(Person.class) method) and making sure
> that further queries for that Person instance returns address when we try to
> access that field.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)