users@glassfish.java.net

Re: COMMUNITY HELP: GlassFish V3 admin console improvements

From: <glassfish_at_javadesktop.org>
Date: Tue, 04 Dec 2007 13:28:56 PST

yea, ok.

I was just making sure I hadn't missed anything, some clever Toplink tweak I could use.

It's remarkably difficult to clear that cache, it seems to me.

You can use the refresh hint, but then, like you said, you need to reload everything -- expensive for a large dataset.

You can em.refresh stuff specifically, but that's even worse (100 items == 100 SQL calls...Ronald McOuchies...)

I wish that the "UPDATE" behavior was better documented on how it affects the cache. Because the EM is cognizant of dynamic EQL update statements, and I'm pretty sure it doesn't go to the level of actually "interpreting" the update statement and applying updates to the cached values as well and feeding an update statement to the database. But I don't know how "smart" it is either. You'd like to think it would be smart enough for something like:
[code]
update Customer c set name = 'Bob' where c.id='123'
[/code]
and not nuke the entire customer cache (rather simply refreshing id 123, because it "knows" id in the PK for customer, or whatever).

But when it finds some kind of update that is Just Too Much, it simply dumps the cache and reloads it lazily from the DB. (Too a point, obviously some items may be in transactions or something.)

But if that's the case, then maybe you can send something like:
[code]
update Customer c set name = name where 1 = 0
[/code]

If the DB is smart enough to not table scan the table trying to find the reclusive record where 1 DOES equal 0 (yes, I've seen it happen), and rather just short circuits the entire query, then there you have a "cheap", do nothing query that the JPA "can't handle", so it becomes a cheap backdoor to reset an entire classes cache. Then your "reset button" can just send a series of those for the important tables in the application.

But I dunno how that all works out, have to play with it sometime.

Still a lot of hoops to jump through for some basic and, IMHO, necessary functionality.

We just restart the application too...
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=248504