jpa - Eclipselink disable cache for stored procedure -


i have 2 stored procedure calls return user entity. 1 looks see if user registered 2 parameters not included in user entity. if procedure not return users, second stored procedure called register user.

the behavior i'm seeing when called in order, second stored procedure returns user entity cache has fields null. when disable caching returns user object appropriately. seem first call caching user object.

in normal operation user logging in, want cache, not want disable caching first call. want second stored procedure call not use cache. after doing research , testing few options, i've found few options.

this doesn't work on stored procedure:

proc.sethint("javax.persistence.cache.retrievemode", cacheretrievemode.bypass);  java.lang.illegalargumentexception: query linkuser, query hint javax.persistence.cache.retrievemode not valid type of query. 

this looks evicts cache users.

em.getentitymanagerfactory().getcache().evict(user.class); 

and these options either disable cache instances of entity or across application.

  1. how can not use cache single stored procedure call eclipselink?

  2. bonus: why stored procedure call returns null user cached?

the jpa specification requires entities returned jpa queries (which includes native , stored proc queries) managed, implies cached maintain object identity. if first query returning incomplete entity, cached. applications need careful when using queries return entities return complete set of data or can corrupt cache, , note entities may pulled cache instead of rebuilt data query, , may want return java objects (constructor queries) rather jpa entities.

for answer first part, see https://stackoverflow.com/a/4471109/496099


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -