|
|
Opensessioninviewfilter as demand its possible?
Hello all,
Is there any way to configure the OpenSessionInViewFilter on demand?
Scan the request attributes and verify if exists one with lazy attributes to improve performance.
Correct me if I'm thinking wrong.
And how would that improve performance, imho the performance you gain you loose by scanning the object (and referenced objects) for lazy properties.
@rrigoni,
I agree with Marten, depending on the object graph depth quot;analyzingquot; will be more expensive than opening a new Session.
But maybe what you can do, is to play with quot;ucl-patternquot; ( if you, for example use it as a filter ) to make sure that some simple pages that do not deal with object graph traversal are not intercepted by this filter.
In spring webflow you can use quot;criteriaquot; for Jpa/Hibernate FlowExecution listeners:Code:
lt;webflow:listener ref=quot;persistenceListenerquot; criteria=quot;onlyForFlow1,andFlow2quot;/gt; And / or mark your flows with quot;lt;persistence-context /gt;quot; to enable / disable Session / EntityManager creation.
This of course has a drawback: quot;You need to remember low level details about which view traverses the object graphquot;. This can be especially painful during quot;coming back to a long forgotten applicationquot; situations.
But to conclude the spiel, I would not recommend to optimize something that does not scream for optimization. Here are my three favorite optimization aphorisms that Josh Bloch shared in his Effective Java series:
Code:
More computing sins are committed in the name of efficiency (without necessarily achieving it) than
for any other single reason—including blind stupidity.
—William A. Wulf 1
We should forget about small efficiencies, say about 97% of the time: premature optimization is
the root of all evil.
—Donald E. Knuth 2
We follow two rules in the matter of optimization:
* Rule 1. Don't do it. * Rule 2 (for experts only). Don't do it yet — that is, not until you have a perfectly clear and unoptimized solution.
—M. A. Jackson 3
/Anatoly |
|