You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Don Brady <db...@pobox.com> on 2007/02/08 01:58:59 UTC
Cache with two ConnectionFactories?
I could not figure this out in reading the OpenJPA documentation.
We have just the one database and set of tables, but we need to have two
separate Connection Pools to the same database in order to have two
different userid's.
(We want to set the priorities on the database differently for access by
the two different usernames).
One is to be used for updates and short queries, and the other for
queries expected to give large result sets.
In these circumstances, is it possible to use the Data Cache and the
Query Cache?
I am worried that if a new entity / data row is created in the Data
Cache under one userid/pool/connectionFactory, it will not show up in
the Query Cache for the other userid/pool/connectionFactory if a query
is done.
Thanks and if this is off-topic please let me know.
Maybe the thing to do would be to have a cache enabled for the
userid/pool/connectionFactory used for short queries and updates, but no
cache for the userid/pool/connectionFactory?
Don
RE: Cache with two ConnectionFactories?
Posted by Patrick Linskey <pl...@bea.com>.
There are a lot of things that you could do. The simplest, and least
cache-effective, would be to have two different EMFs that each have
their own caches. These caches could be linked together (using the sjvm
remote commit provider), so that data would stay consistent, but
otherwise, this would be like using different databases.
If you can access the same data via both data sources, the other option
would be to create your own data source that uses a ThreadLocal or
something to decide which underlying data source to use, and tell
OpenJPA to use that data source. Then, depending on the use case, you
could select a different data source.
Or, if the only thing that you need is different connection credentials
when logging in, you could use a single data source and call
EMF.createEntityManager(Map) with openjpa.ConnectionUserName and
openjpa.ConnectionPassword key-value pairs in the map.
Hope that helps,
-Patrick
--
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
Notice: This email message, together with any attachments, may contain
information of BEA Systems, Inc., its subsidiaries and affiliated
entities, that may be confidential, proprietary, copyrighted and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.
> -----Original Message-----
> From: Don Brady [mailto:dbrady@pobox.com]
> Sent: Wednesday, February 07, 2007 4:59 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: Cache with two ConnectionFactories?
>
> I could not figure this out in reading the OpenJPA documentation.
>
> We have just the one database and set of tables, but we need
> to have two
> separate Connection Pools to the same database in order to have two
> different userid's.
>
> (We want to set the priorities on the database differently
> for access by
> the two different usernames).
>
> One is to be used for updates and short queries, and the other for
> queries expected to give large result sets.
>
> In these circumstances, is it possible to use the Data Cache and the
> Query Cache?
>
> I am worried that if a new entity / data row is created in the Data
> Cache under one userid/pool/connectionFactory, it will not show up in
> the Query Cache for the other userid/pool/connectionFactory
> if a query
> is done.
>
> Thanks and if this is off-topic please let me know.
>
> Maybe the thing to do would be to have a cache enabled for the
> userid/pool/connectionFactory used for short queries and
> updates, but no
> cache for the userid/pool/connectionFactory?
>
> Don
>