Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Native Queries and ResultSetMapping - caching problem(We want to perform two native queries on the same ResultSetMapping. Between the two queries, we manually update the object in OracleDb: we would like to see in the second query result the new manually)
Native Queries and ResultSetMapping - caching problem [message #1745110] Wed, 05 October 2016 09:47 Go to next message
Matteo Ferrari is currently offline Matteo FerrariFriend
Messages: 1
Registered: October 2016
Junior Member
Hi all,
we are experiencing a strange behaviour while executing NativeQueries with ResultSetMapping.

In short: we want to perform two native queries on the same ResultSet (LxObjAndLxSymb); between the two queries, we manually update the object in OracleDb: we would like to see in the second query result the new manually updated value, but we don't.

I'll try to explain with some code:


LxSymb symbBeforeManualUpdate = null, symbAfterManualUpdate = null;

//The first query

Query query = entityManager.createNativeQuery("SELECT obj.*, symb.* FROM lx_symb symb, lx_obj obj WHERE symb.obj_id = obj.obj_id and symb.symb_id = 405430", "LxObjAndLxSymb");
List<Object[]> retList = (List<Object[]>) query.getResultList();

symbBeforeManualUpdate = (LxSymb)retList.get(0)[1];

// **************************************************************
//
// Let's suppose symbBeforeManualUpdate .prop1 = 10;
// Then we manually update the LxSymb.prop1 value to 33 in ORACLE DB (e.g. via sqlplus)
//
// **************************************************************

//The second query

Query query2 = entityManager.createNativeQuery("SELECT obj.*, symb.* FROM lx_symb symb, lx_obj obj WHERE symb.obj_id = obj.obj_id and symb.symb_id = 405430", "LxObjAndLxSymb");
List<Object[]> retList2 = (List<Object[]>) query2.getResultList();

symbAfterManualUpdate = (LxSymb)retList2.get(0)[1];

// **************************************************************
//
//  We would expect to see symbAfterManualUpdate .prop1=33, instead we have symbAfterManualUpdate .prop1=10
//
// **************************************************************



Please note that we are not interested at all to cache, since in our environment we have many different actors writing and reading from/to database: we just need to always have fresh data at each query:


  • with NamedQueries, we are using proper Hints (QueryHints.CACHE_RETRIEVE_MODE=CacheRetrieveMode.BYPASS and QueryHints.CACHE_STORE_MODE=CacheStoreMode.REFRESH) and seems to be ok
  • with NativeQueries WITHOUT ResultSetMapping we are using Hint (QueryHints.CACHE_STORE_MODE=CacheStoreMode.REFRESH) and seems to be ok
  • NativeQueries WITH does not support CACHE_STORE_MODE hint, so the problem.


How can I force ResultSetMapping Native queries always have aligned data with Oracle DB?
And in general, how can I make eclipselink always ignore all kind of caches?

Thanks in advance for any help,
Matteo


Re: Native Queries and ResultSetMapping - caching problem [message #1745561 is a reply to message #1745110] Wed, 12 October 2016 13:47 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
Does the QueryHints.REFRESH hint, "eclipselink.refresh" work on these queries?
Previous Topic:Criteria Distinct on (column)
Next Topic:Moxy - supported xPath version?
Goto Forum:
  


Current Time: Fri Dec 15 06:34:30 GMT 2017

Powered by FUDForum. Page generated in 0.01625 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software