openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Gersdorf <joern.gersd...@gmail.com>
Subject Re: Enable Query Cache, but selectively
Date Wed, 12 Nov 2014 08:19:14 GMT
Hi Rick,

first of all thank you for providing the OSGi-Classloading-Patch in
OPENJPA-2542 so quickly. It´s working fine.

No, I do not need a custom BrokerFactory for anything else at the current
moment, just for having (a) QueryCache enabled in general, but disabled in
the FetchPlan by default (b) possibility to _enable_ the QueryCache on
occasion using query.getFetchPlan().setQueryResult(true).

Currently, unfortunately, only the other way around is supported by
configuration properties.

So I´ve opened a proposal for adding a configuration property at
https://issues.apache.org/jira/browse/OPENJPA-2543.

Kind regards,
Jörn


On Tue, Nov 11, 2014 at 4:40 PM, Rick Curtis <curtisr7@gmail.com> wrote:

> Is there any other reason that you need a custom BrokerFactory than this
> bit of functionality?
>
> On Tue, Nov 11, 2014 at 8:53 AM, Jörn Gersdorf <joern.gersdorf@gmail.com>
> wrote:
>
> > Hi all,
> >
> > I´ve reported the OSGi ClassLoader issue as
> > https://issues.apache.org/jira/browse/OPENJPA-2542.
> >
> > Kind regards,
> > Jörn
> >
> > On Tue, Nov 11, 2014 at 3:33 PM, Jörn Gersdorf <joern.gersdorf@gmail.com
> >
> > wrote:
> >
> > > Hi Rick,
> > >
> > > thanks for you thought. The reason I´m using the custom
> JDBCBrokerFactory
> > > is that I want to have the QueryCache disabled _by default_ and only
> > enable
> > > it on occasion. With the out-of-the-box-JDBCBrokerFactory it´s only
> > > possible the other way around (disable on occasion).
> > >
> > > Now, my custom JDBCBrokerFactory is working in a non-OSGi-Environment.
> > > Unfortunately, due to OPENJPA-1491, I´m currently not able to load my
> > > custom JDBCBrokerFactory (which is living in my own bundle) as openjpa
> > > will only load a BrokerFactory using the OpenJPA-Bundle´s classloader.
> > >
> > > Kind regards,
> > > Jörn
> > >
> > > On Mon, Nov 10, 2014 at 7:24 PM, Rick Curtis <curtisr7@gmail.com>
> wrote:
> > >
> > >> > However I wonder if there is an easier way to achieve this?
> > >> I thought there was an easier way... but after digging around a bit I
> > >> didn't come up with anything better. While what you are doing is
> > >> completely
> > >> valid, I'd almost recommend the creation of a helper method that will
> > >> disable/enable the QueryReultsCache when you create a query. A custom
> > >> JDBCBrokerFactory seems like quite a lot of complexity when you could
> > just
> > >> call .setQueryCacheEnabled(false) when you do/don't want caching...
> then
> > >> again, that is just my opinion.
> > >>
> > >> I think the ideal solution would involve the addition of a new
> > >> configuration property to OpenJPAConfigurationImpl. Something similar
> to
> > >> openjpa.MaxFetchDepth[1].
> > >>
> > >> Thanks,
> > >> Rick
> > >>
> > >> [1]
> > >>
> > >>
> >
> http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#openjpa.MaxFetchDepth
> > >>
> > >> On Mon, Nov 10, 2014 at 1:30 AM, Jörn Gersdorf <
> > joern.gersdorf@gmail.com>
> > >> wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > I´d like to enable OpenJPA´s query cache in a selective way, i.
e.
> it
> > >> > should be disabled unless I enable it explicitly using
> > >> > query.getFetchPlan().setQueryResult(true).
> > >> >
> > >> > I´ve figured out that this requires
> > >> > FetchConfigurationImpl$ConfigurationState#queryCache to be set to
> > false
> > >> by
> > >> > default, however, there does not seem to be a configuration property
> > for
> > >> > this.
> > >> >
> > >> > So I ended up subclassing JDBCBrokerFactory and configure this via
> > >> property
> > >> > openjpa.BrokerFactory (see code below).
> > >> >
> > >> > However I wonder if there is an easier way to achieve this?
> > >> >
> > >> > Thanks and best regards,
> > >> > Jörn
> > >> >
> > >> > Code:
> > >> >
> > >> > <property name="openjpa.BrokerFactory"
> > >> > value="de.dwpbank.wp2d.wprecon.model.cache.CustomJDBCBrokerFactory"
> />
> > >> >
> > >> >
> > >> > public class CustomJDBCBrokerFactory extends JDBCBrokerFactory {
> > >> >
> > >> >     public CustomJDBCBrokerFactory(JDBCConfiguration conf) {
> > >> >         super(conf);
> > >> >     }
> > >> >
> > >> >     @Override
> > >> >     protected StoreManager newStoreManager() {
> > >> >         return new JDBCStoreManager() {
> > >> >             @Override
> > >> >             public FetchConfiguration newFetchConfiguration() {
> > >> >                 return
> > >> > super.newFetchConfiguration().setQueryCacheEnabled(false);
> > >> >             }
> > >> >         };
> > >> >     }
> > >> >
> > >> >     public static CustomJDBCBrokerFactory
> > >> newInstance(ConfigurationProvider
> > >> > cp) {
> > >> >         JDBCConfigurationImpl conf = new JDBCConfigurationImpl();
> > >> >         cp.setInto(conf);
> > >> >         return new CustomJDBCBrokerFactory(conf);
> > >> >     }
> > >> > }
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> *Rick Curtis*
> > >>
> > >
> > >
> >
>
>
>
> --
> *Rick Curtis*
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message