Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] QueryHints Issue !!!

I am not sure exactly what you mean, so I'll start by make a general warning; Performing a refresh when there are changes can be risky, as it essentially resets the refreshed entity to what it is in the database. Any changes you make that are not in the database might be lost. And as cascade refresh/all seem to be overused, performing a refresh over an object tree can cause unintentionally wiping out changes to the tree. Please note that refresh also resets lazy relationships, so that if you have A->B lazy relation marked cascade refresh and refresh A, then later on find and make changes to B in the same context, these changes might be wiped out when you access

That said, what you are experience sounds like if you are updating you should flush the change before you issue a query that might cause a refresh. Calling flush pushes the changes to the database so that they are picked up when the refresh occurs.

Best Regards,
Chris

On 18/09/2012 3:32 PM, vaidya nathan wrote:
Hi Eclipselink users,

We are using eclipselink 2.4.0 and having a problem that is mystifying.
We are using jboss as our container , and spring jta to write data and
so far so good. While testing we found that whenever we make a change to
the database directly the data is not getting refreshed automatically
(The eclipselink cache is not getting refreshed automatically). So we
introduced a hint something like

  Query jpaq = JpaHelper.createQuery(query, getEntityManager()) ;
  jpaq.setHint(QueryHints.REFRESH, HintValues.TRUE) ;

and with this it is refreshing . But the problem with this approach is
that if we have an update and read within the same transaction , it is
not working. i think that the first update is just merging to the cache
but when we do a find it is going and re reading it from the database
and so am not getting the updates. How do i configure the hint to work
in both the cases?

Cheers
Vaidya



_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top