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.gersd...@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.gersd...@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 <curti...@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.gersd...@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*

Reply via email to