Hi Oleg, I don't think there's a workaround available. This sounds like a good candidate for an improvement though. Could you open a JIRA issue<https://issues.apache.org/jira/browse/OPENJPA>, and vote for it?
The model you listed in your first email to the list should reproduce the problem, but if you can include a unit test as well that will probably help. -mike On Fri, May 20, 2011 at 2:04 AM, LYALIKOV, OLEG (OLEG)** CTR ** < [email protected]> wrote: > Thanks for reply Kevin. > Actually there are no any exceptions or errors. > > Imagine situation: you have a query "SELECT x FROM A WHERE x.title = 'Some > title'". You execute this query a lot of times so openjpa can return cached > query result (I assume this is QueryCache). > > But then you for example create new object of type B. > After create openjpa checks cached queries and finds query "SELECT x FROM A > WHERE x.title = 'Some title'" which access path (field _accessPathClassNames > in QueryKey class) contains class A and class Base and this access path > intersects with access path of create query (it contains class B and class > Base). > So openjpa decides to remove query "SELECT x FROM A WHERE x.title = 'Some > title'" result from cache and when you run this query next time openjpa > accesses database. > > But entity Base doesn't have own table, its fields are contained as in > table A as in table B and tables A and B don't intersect. > So decision to remove query "SELECT x FROM A WHERE x.title = 'Some title'" > result from cache after creating object of class B seems wrong to me. > > Openjpa considers entities A and B intersect through their base persistent > entity Base but actually they don't intersect. > > Thanks > Oleg > > -----Original Message----- > From: Kevin Sutter [mailto:[email protected]] > Sent: Thursday, May 19, 2011 7:30 PM > To: [email protected] > Subject: Re: Query cache eviction problem with > InheritanceType.TABLE_PER_CLASS > > HI Oleg, > Can you post the specific exception or error condition you are referring > to? OpenJPA utilizes several caches. It sounds like you might be > referring > to the QuerySQLCache not being able to cache the generated SQL. This is > different from the QueryCache which caches the results of various Queries. > Just trying to clarify which cache you are experiencing problems with. > > Thanks, > Kevin > > On Thu, May 19, 2011 at 7:28 AM, LYALIKOV, OLEG (OLEG)** CTR ** < > [email protected]> wrote: > > > Hello, > > I'm using openjpa-2.0.0 and have some base class > > > > @Entity > > @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) > > public abstract class Base { ... } > > > > and also some inheritors > > > > @Entity > > @Inheritance(strategy = InheritanceType.JOINED) > > public class A extends Base { ... } > > > > @Entity > > @Inheritance(strategy = InheritanceType.JOINED) > > public class B extends Base { ... } > > > > Base class has some fields which are used as in A as in B class but these > > fields are in separate tables (for A and B class) with no common table. > > > > The problem is: if I have cached query involving A class and then I > > create/update/delete object of B class then I get invalidated query for > > class A because both A and B class have common persistent class Base and > > openjpa decides that changing object of class B affects cached queries > > involving class A which is not true (I have two separate tables - one for > A > > and one for B class). > > > > This is significant problem for me because I have lots of inheritors of > > Base class and all these inheritors have own table and don't have some > > common table and these query cache invalidates slow system. > > > > Is there any workaround? I tried extending QueryCache implementations but > > with no success (for example removing Base class from access path of > > QueryKey object didn't help because of some other realization details of > > QueryKey object which I can't change) > > >
