You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Guillaume Nodet <gu...@deliasystems.com> on 2004/04/21 14:42:29 UTC

Problem with clearing cache

I need to clear the ojb cache at some point in my program
(namely after deleting all data in the database).
The problem i have is that i use anonymous primary keys and
the caches associated with the anonymous fields are not cleared.
Would it be possible to had some mean of clearing these caches ?

The problem is that at some time, i've got errors when inserting
objects. I think that the key for the failing object is in cache
but not in the database so when a foreign key references it, 
the insertion fails.

Thanks, 
Guillaume Nodet

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with clearing cache

Posted by Guillaume Nodet <gu...@deliasystems.com>.
I could use a per-broker cache but i don't think
this will solve my problem.

Imho, per-broker cache does not work with anonymous fields because
the cache is stored within the anonymous field descriptors, which are
common to all brokers (i think).
Maybe the cache should be responsible for anonymous keys ?

For the moment, i think i will patch the anonymous field descriptor
to add a clearCache method and iterate through the class descriptors
to clear all anonymous keys caches, but this is not a very
pretty solution.

Guillaume


-----Message d'origine-----
De : Brian McCallister [mailto:mccallister@forthillcompany.com]
Envoyé : mercredi 21 avril 2004 15:34
À : OJB Users List
Objet : Re: Problem with clearing cache


I would tend to say that using anonymous primary keys and clearing the
cache are mutually exclusive operations, unfortunately, as the cache is
where the primary keys are stored.

Is using a per-broker cache an option? If so you will effectively have
the cache cleared every time you obtain a new broker/close a broker.

-Brian

On Apr 21, 2004, at 8:52 AM, Guillaume Nodet wrote:

> I thought i could replace the default implementation
> of persistend field with my own, but i saw no way
> of doing this for anonymous fields. Why is this class
> not configurable along with the other ones in the
> ojb configuration file ? I know my needs may be
> very specific, but ...
>
> Cheers
>
> Guillaume Nodet
>
> -----Message d'origine-----
> De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
> Envoyé : mercredi 21 avril 2004 14:42
> À : OJB Users List
> Objet : Problem with clearing cache
>
>
> I need to clear the ojb cache at some point in my program
> (namely after deleting all data in the database).
> The problem i have is that i use anonymous primary keys and
> the caches associated with the anonymous fields are not cleared.
> Would it be possible to had some mean of clearing these caches ?
>
> The problem is that at some time, i've got errors when inserting
> objects. I think that the key for the failing object is in cache
> but not in the database so when a foreign key references it,
> the insertion fails.
>
> Thanks,
> Guillaume Nodet
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with clearing cache

Posted by Brian McCallister <mc...@forthillcompany.com>.
I would tend to say that using anonymous primary keys and clearing the 
cache are mutually exclusive operations, unfortunately, as the cache is 
where the primary keys are stored.

Is using a per-broker cache an option? If so you will effectively have 
the cache cleared every time you obtain a new broker/close a broker.

-Brian

On Apr 21, 2004, at 8:52 AM, Guillaume Nodet wrote:

> I thought i could replace the default implementation
> of persistend field with my own, but i saw no way
> of doing this for anonymous fields. Why is this class
> not configurable along with the other ones in the
> ojb configuration file ? I know my needs may be
> very specific, but ...
>
> Cheers
>
> Guillaume Nodet
>
> -----Message d'origine-----
> De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
> Envoyé : mercredi 21 avril 2004 14:42
> À : OJB Users List
> Objet : Problem with clearing cache
>
>
> I need to clear the ojb cache at some point in my program
> (namely after deleting all data in the database).
> The problem i have is that i use anonymous primary keys and
> the caches associated with the anonymous fields are not cleared.
> Would it be possible to had some mean of clearing these caches ?
>
> The problem is that at some time, i've got errors when inserting
> objects. I think that the key for the failing object is in cache
> but not in the database so when a foreign key references it,
> the insertion fails.
>
> Thanks,
> Guillaume Nodet
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with clearing cache

Posted by Thomas Dudziak <to...@first.gmd.de>.
On Wed, 21 Apr 2004, Guillaume Nodet wrote:

> I thought i could replace the default implementation
> of persistend field with my own, but i saw no way
> of doing this for anonymous fields. Why is this class
> not configurable along with the other ones in the
> ojb configuration file ? I know my needs may be
> very specific, but ...

This does not seem to be so simple as the two AnonymousField 
implementations are hardcoded in several places. Seems some refactoring of
this part is in order. I'd do it but only if it is not urgent as I don't
have any time to work on OJB in the next two weeks.

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with clearing cache

Posted by Guillaume Nodet <gu...@deliasystems.com>.
I thought i could replace the default implementation
of persistend field with my own, but i saw no way
of doing this for anonymous fields. Why is this class
not configurable along with the other ones in the
ojb configuration file ? I know my needs may be
very specific, but ...

Cheers

Guillaume Nodet

-----Message d'origine-----
De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
Envoyé : mercredi 21 avril 2004 14:42
À : OJB Users List
Objet : Problem with clearing cache


I need to clear the ojb cache at some point in my program
(namely after deleting all data in the database).
The problem i have is that i use anonymous primary keys and
the caches associated with the anonymous fields are not cleared.
Would it be possible to had some mean of clearing these caches ?

The problem is that at some time, i've got errors when inserting
objects. I think that the key for the failing object is in cache
but not in the database so when a foreign key references it,
the insertion fails.

Thanks,
Guillaume Nodet

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with clearing cache

Posted by Armin Waibel <ar...@apache.org>.
Hi Guillaume,

Guillaume Nodet wrote:
> What about using runtime byte-code enhancement, as you mentioned it,
> to extends classes to dynamically add properties for storing AKs,
> thus removing the need of AnonymousPersistentField ...
> 

you stir up a hornet's nest ;-)

Many people don't like manipulation of persistent object classes 
(dynamically or pre-compiled). Another problem will be the use of the 
"correct" classloader when dynamically enhancement was used and the user 
can't create persistent objects by it's own.

But indeed byte code enhancement will solve or simplify many problems 
(e.g. anonymous fields, object state detection, object locking, ...).
I don't have experience in bytecode manipulation (only played a little 
with ASM) but all suggestions, pros and cons are welcome.

regards,
Armin


> Guillaume
> 
> -----Message d'origine-----
> De : Armin Waibel [mailto:arminw@apache.org]
> Envoyé : jeudi 22 avril 2004 15:01
> À : OJB Users List
> Objet : Re: Problem with clearing cache
> 
> 
> Hi Guillaume,Brian,
> 
> I think the anonymous key (AK) feature should be modified/rewriten
> because currently it is object identity based. This means you will loose
> all AK information when the object will be de-/serialized or copied. The
> upcoming two-level cache will do so and the OTM implementation too (and
> my "feeling" is that this will cause problems).
> The AK in conjunction with 1:1 references are always be save (I think),
> because when the AK information is lost, we can use the reference to
> re-create the AK information.
> 
>  > I'm willingfull to help refactoring this part, but i'd like to
>  > have guidelines
> 
> sorry I don't have any ideas (without byte-code enhancement ;-))
> 
>  > if anonymous keys are integrated within the existing cache system,
>  > but i have no ideas on how to do it.
> 
> this will be difficult, because AK implementation does not know about
> the cache and the cache could be per class-descriptor, per connection or
> global.
> 
> regards,
> Armin
> 
> Guillaume Nodet wrote:
> 
> 
>>I use both anonymous PK's and FK's. But the use i do of anonymous
>>primary keys is limited to objects that belongs to collections of
>>main objects.  Main objects have *real* primary keys and only
>>these ones are used directly in the broker (all collections are
>>prefetched) and cached. So i think that using anonymous pk's in
>>my case is safe (if my understanding is good, problems can arise
>>when using anonymous pk's in distributed environnments).
>>
>>So the main problem is the caching system
>>for anonymous keys (either pk or fk) :
>>  * keys are kept in a cache specific to the field
>>  * this cache can not be accessed by any means so no clear
>>      is possible
>>  * this cache can not be a per-broker cache
>>  * anonymous persistent fields implementation
>>      can not be extended or overriden
>>
>>I'm willingfull to help refactoring this part, but i'd like to
>>have guidelines on how to do it...
>>I think it would be great
>>if anonymous keys are integrated within the existing cache system,
>>but i have no ideas on how to do it.
>>
>>Guillaume
>>
>>
>>-----Message d'origine-----
>>De : Brian McCallister [mailto:mccallister@forthillcompany.com]
>>Envoyé : jeudi 22 avril 2004 14:06
>>À : OJB Users List
>>Objet : Re: Problem with clearing cache
>>
>>
>>Anonymous PK's are risky things -- I apologize for using them in the
>>original anonymous keys tutorial. Anonymous FK's are great, and not
>>using them is usually a bad ida in my opinion =)
>>
>>I don't think the anonymous PK issues you are having will be resolved
>>very soon, the anonymous key functionality wasn't really designed for
>>PK usage, but for FK usage. I completely feel that it would be good to
>>be able to use them for PK's as well, but my slate is full at the
>>moment with JDO stuff =(
>>
>>I don't know about everyone else. Any chance *you* want to dig into it?
>>;-)
>>
>>-Brian
>>
>>On Apr 22, 2004, at 7:55 AM, Guillaume Nodet wrote:
>>
>>
>>
>>>It also seems that cached anonymous keys are not removed from
>>>the cache when an object is deleted from database.
>>>Will these problems be solved, or should i try not to use
>>>anonymous keys ?
>>>
>>>Guillaume
>>>
>>>-----Message d'origine-----
>>>De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
>>>Envoyé : mercredi 21 avril 2004 14:42
>>>À : OJB Users List
>>>Objet : Problem with clearing cache
>>>
>>>
>>>I need to clear the ojb cache at some point in my program
>>>(namely after deleting all data in the database).
>>>The problem i have is that i use anonymous primary keys and
>>>the caches associated with the anonymous fields are not cleared.
>>>Would it be possible to had some mean of clearing these caches ?
>>>
>>>The problem is that at some time, i've got errors when inserting
>>>objects. I think that the key for the failing object is in cache
>>>but not in the database so when a foreign key references it,
>>>the insertion fails.
>>>
>>>Thanks,
>>>Guillaume Nodet
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with sequence manager

Posted by Guillaume Nodet <gu...@deliasystems.com>.
It should be ok.
The reset name seems fine to me.

Thanks,
Guillaume

-----Message d'origine-----
De : Armin Waibel [mailto:arminw@apache.org]
Envoyé : vendredi 23 avril 2004 18:08
À : OJB Users List
Objet : Re: Problem with sequence manager


Guillaume Nodet wrote:

> I only added the following method:
>
> 	public static void clearCache() {
> 		if (sequencesMap != null) {
> 			sequencesMap.clear();
> 		}
> 	}
>

It should be no problem to add such a method, but I can't change the
sequence manager interface (maybe for 1.1), so you have to cast. Maybe
we call the method 'reset()' and introduce this method in sequence
manager interface for 1.1.
In reset() method depended on the implementation the sequence manager
was set to an initial state.
What do you think? Better method name?

regards,
Armin

> and called it when i destroy the tables, and everything
> works fine now.
>
> -----Message d'origine-----
> De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
> Envoyé : vendredi 23 avril 2004 16:25
> À : OJB Users List
> Objet : Problem with sequence manager
>
>
> Hi,
>
> In my application, i can dynamically create and drop the tables
> for storing ojb objects. The problem is that when i insert some
> data, drop the tables, recreate them, and insert data, the sequence
> manager is not re-initialized (i use SequenceManagerHighLowImpl)
> so when inserting data in the newly created tables, the sequence
> manager reuses caches sequences (in the sequencesMap), instead
> of creating new ones. So when a sequence runs out of id, it looks
> into the database, creates a new sequence and thus ids overlapp.
>
> Could it be possible to add a method for clearing the cache of
> sequences (stored in the sequencesMap attribute) ?
>
> I will for the moment use my own sequence manager (a copy of
> SequenceManagerHighLowImpl with the above method).
>
> Thanks,
>
> Guillaume
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with sequence manager

Posted by Armin Waibel <ar...@apache.org>.
Guillaume Nodet wrote:

> I only added the following method:
> 
> 	public static void clearCache() {
> 		if (sequencesMap != null) {
> 			sequencesMap.clear();
> 		}
> 	}
>

It should be no problem to add such a method, but I can't change the 
sequence manager interface (maybe for 1.1), so you have to cast. Maybe 
we call the method 'reset()' and introduce this method in sequence 
manager interface for 1.1.
In reset() method depended on the implementation the sequence manager 
was set to an initial state.
What do you think? Better method name?

regards,
Armin

> and called it when i destroy the tables, and everything
> works fine now.
> 
> -----Message d'origine-----
> De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
> Envoyé : vendredi 23 avril 2004 16:25
> À : OJB Users List
> Objet : Problem with sequence manager
> 
> 
> Hi,
> 
> In my application, i can dynamically create and drop the tables
> for storing ojb objects. The problem is that when i insert some
> data, drop the tables, recreate them, and insert data, the sequence
> manager is not re-initialized (i use SequenceManagerHighLowImpl)
> so when inserting data in the newly created tables, the sequence
> manager reuses caches sequences (in the sequencesMap), instead
> of creating new ones. So when a sequence runs out of id, it looks
> into the database, creates a new sequence and thus ids overlapp.
> 
> Could it be possible to add a method for clearing the cache of
> sequences (stored in the sequencesMap attribute) ?
> 
> I will for the moment use my own sequence manager (a copy of
> SequenceManagerHighLowImpl with the above method).
> 
> Thanks,
> 
> Guillaume
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with sequence manager

Posted by Guillaume Nodet <gu...@deliasystems.com>.
I only added the following method:

	public static void clearCache() {
		if (sequencesMap != null) {
			sequencesMap.clear();
		}
	}

and called it when i destroy the tables, and everything
works fine now.

-----Message d'origine-----
De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
Envoyé : vendredi 23 avril 2004 16:25
À : OJB Users List
Objet : Problem with sequence manager


Hi,

In my application, i can dynamically create and drop the tables
for storing ojb objects. The problem is that when i insert some
data, drop the tables, recreate them, and insert data, the sequence
manager is not re-initialized (i use SequenceManagerHighLowImpl)
so when inserting data in the newly created tables, the sequence
manager reuses caches sequences (in the sequencesMap), instead
of creating new ones. So when a sequence runs out of id, it looks
into the database, creates a new sequence and thus ids overlapp.

Could it be possible to add a method for clearing the cache of
sequences (stored in the sequencesMap attribute) ?

I will for the moment use my own sequence manager (a copy of
SequenceManagerHighLowImpl with the above method).

Thanks,

Guillaume

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Problem with sequence manager

Posted by Guillaume Nodet <gu...@deliasystems.com>.
Hi,

In my application, i can dynamically create and drop the tables
for storing ojb objects. The problem is that when i insert some
data, drop the tables, recreate them, and insert data, the sequence
manager is not re-initialized (i use SequenceManagerHighLowImpl)
so when inserting data in the newly created tables, the sequence
manager reuses caches sequences (in the sequencesMap), instead
of creating new ones. So when a sequence runs out of id, it looks
into the database, creates a new sequence and thus ids overlapp.

Could it be possible to add a method for clearing the cache of
sequences (stored in the sequencesMap attribute) ?

I will for the moment use my own sequence manager (a copy of
SequenceManagerHighLowImpl with the above method).

Thanks,

Guillaume

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with clearing cache

Posted by Guillaume Nodet <gu...@deliasystems.com>.
What about using runtime byte-code enhancement, as you mentioned it,
to extends classes to dynamically add properties for storing AKs,
thus removing the need of AnonymousPersistentField ...

Guillaume

-----Message d'origine-----
De : Armin Waibel [mailto:arminw@apache.org]
Envoyé : jeudi 22 avril 2004 15:01
À : OJB Users List
Objet : Re: Problem with clearing cache


Hi Guillaume,Brian,

I think the anonymous key (AK) feature should be modified/rewriten
because currently it is object identity based. This means you will loose
all AK information when the object will be de-/serialized or copied. The
upcoming two-level cache will do so and the OTM implementation too (and
my "feeling" is that this will cause problems).
The AK in conjunction with 1:1 references are always be save (I think),
because when the AK information is lost, we can use the reference to
re-create the AK information.

 > I'm willingfull to help refactoring this part, but i'd like to
 > have guidelines

sorry I don't have any ideas (without byte-code enhancement ;-))

 > if anonymous keys are integrated within the existing cache system,
 > but i have no ideas on how to do it.

this will be difficult, because AK implementation does not know about
the cache and the cache could be per class-descriptor, per connection or
global.

regards,
Armin

Guillaume Nodet wrote:

> I use both anonymous PK's and FK's. But the use i do of anonymous
> primary keys is limited to objects that belongs to collections of
> main objects.  Main objects have *real* primary keys and only
> these ones are used directly in the broker (all collections are
> prefetched) and cached. So i think that using anonymous pk's in
> my case is safe (if my understanding is good, problems can arise
> when using anonymous pk's in distributed environnments).
>
> So the main problem is the caching system
> for anonymous keys (either pk or fk) :
>   * keys are kept in a cache specific to the field
>   * this cache can not be accessed by any means so no clear
>       is possible
>   * this cache can not be a per-broker cache
>   * anonymous persistent fields implementation
>       can not be extended or overriden
>
> I'm willingfull to help refactoring this part, but i'd like to
> have guidelines on how to do it...
> I think it would be great
> if anonymous keys are integrated within the existing cache system,
> but i have no ideas on how to do it.
>
> Guillaume
>
>
> -----Message d'origine-----
> De : Brian McCallister [mailto:mccallister@forthillcompany.com]
> Envoyé : jeudi 22 avril 2004 14:06
> À : OJB Users List
> Objet : Re: Problem with clearing cache
>
>
> Anonymous PK's are risky things -- I apologize for using them in the
> original anonymous keys tutorial. Anonymous FK's are great, and not
> using them is usually a bad ida in my opinion =)
>
> I don't think the anonymous PK issues you are having will be resolved
> very soon, the anonymous key functionality wasn't really designed for
> PK usage, but for FK usage. I completely feel that it would be good to
> be able to use them for PK's as well, but my slate is full at the
> moment with JDO stuff =(
>
> I don't know about everyone else. Any chance *you* want to dig into it?
> ;-)
>
> -Brian
>
> On Apr 22, 2004, at 7:55 AM, Guillaume Nodet wrote:
>
>
>>It also seems that cached anonymous keys are not removed from
>>the cache when an object is deleted from database.
>>Will these problems be solved, or should i try not to use
>>anonymous keys ?
>>
>>Guillaume
>>
>>-----Message d'origine-----
>>De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
>>Envoyé : mercredi 21 avril 2004 14:42
>>À : OJB Users List
>>Objet : Problem with clearing cache
>>
>>
>>I need to clear the ojb cache at some point in my program
>>(namely after deleting all data in the database).
>>The problem i have is that i use anonymous primary keys and
>>the caches associated with the anonymous fields are not cleared.
>>Would it be possible to had some mean of clearing these caches ?
>>
>>The problem is that at some time, i've got errors when inserting
>>objects. I think that the key for the failing object is in cache
>>but not in the database so when a foreign key references it,
>>the insertion fails.
>>
>>Thanks,
>>Guillaume Nodet
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with clearing cache

Posted by Armin Waibel <ar...@apache.org>.
Hi Guillaume,Brian,

I think the anonymous key (AK) feature should be modified/rewriten 
because currently it is object identity based. This means you will loose 
all AK information when the object will be de-/serialized or copied. The 
upcoming two-level cache will do so and the OTM implementation too (and 
my "feeling" is that this will cause problems).
The AK in conjunction with 1:1 references are always be save (I think), 
because when the AK information is lost, we can use the reference to 
re-create the AK information.

 > I'm willingfull to help refactoring this part, but i'd like to
 > have guidelines

sorry I don't have any ideas (without byte-code enhancement ;-))

 > if anonymous keys are integrated within the existing cache system,
 > but i have no ideas on how to do it.

this will be difficult, because AK implementation does not know about 
the cache and the cache could be per class-descriptor, per connection or 
global.

regards,
Armin

Guillaume Nodet wrote:

> I use both anonymous PK's and FK's. But the use i do of anonymous
> primary keys is limited to objects that belongs to collections of
> main objects.  Main objects have *real* primary keys and only
> these ones are used directly in the broker (all collections are
> prefetched) and cached. So i think that using anonymous pk's in
> my case is safe (if my understanding is good, problems can arise
> when using anonymous pk's in distributed environnments).
> 
> So the main problem is the caching system
> for anonymous keys (either pk or fk) :
>   * keys are kept in a cache specific to the field
>   * this cache can not be accessed by any means so no clear
>       is possible
>   * this cache can not be a per-broker cache
>   * anonymous persistent fields implementation
>       can not be extended or overriden
> 
> I'm willingfull to help refactoring this part, but i'd like to
> have guidelines on how to do it...
> I think it would be great
> if anonymous keys are integrated within the existing cache system,
> but i have no ideas on how to do it.
> 
> Guillaume
> 
> 
> -----Message d'origine-----
> De : Brian McCallister [mailto:mccallister@forthillcompany.com]
> Envoyé : jeudi 22 avril 2004 14:06
> À : OJB Users List
> Objet : Re: Problem with clearing cache
> 
> 
> Anonymous PK's are risky things -- I apologize for using them in the
> original anonymous keys tutorial. Anonymous FK's are great, and not
> using them is usually a bad ida in my opinion =)
> 
> I don't think the anonymous PK issues you are having will be resolved
> very soon, the anonymous key functionality wasn't really designed for
> PK usage, but for FK usage. I completely feel that it would be good to
> be able to use them for PK's as well, but my slate is full at the
> moment with JDO stuff =(
> 
> I don't know about everyone else. Any chance *you* want to dig into it?
> ;-)
> 
> -Brian
> 
> On Apr 22, 2004, at 7:55 AM, Guillaume Nodet wrote:
> 
> 
>>It also seems that cached anonymous keys are not removed from
>>the cache when an object is deleted from database.
>>Will these problems be solved, or should i try not to use
>>anonymous keys ?
>>
>>Guillaume
>>
>>-----Message d'origine-----
>>De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
>>Envoyé : mercredi 21 avril 2004 14:42
>>À : OJB Users List
>>Objet : Problem with clearing cache
>>
>>
>>I need to clear the ojb cache at some point in my program
>>(namely after deleting all data in the database).
>>The problem i have is that i use anonymous primary keys and
>>the caches associated with the anonymous fields are not cleared.
>>Would it be possible to had some mean of clearing these caches ?
>>
>>The problem is that at some time, i've got errors when inserting
>>objects. I think that the key for the failing object is in cache
>>but not in the database so when a foreign key references it,
>>the insertion fails.
>>
>>Thanks,
>>Guillaume Nodet
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with clearing cache

Posted by Guillaume Nodet <gu...@deliasystems.com>.
I use both anonymous PK's and FK's. But the use i do of anonymous
primary keys is limited to objects that belongs to collections of
main objects.  Main objects have *real* primary keys and only
these ones are used directly in the broker (all collections are
prefetched) and cached. So i think that using anonymous pk's in
my case is safe (if my understanding is good, problems can arise
when using anonymous pk's in distributed environnments).

So the main problem is the caching system
for anonymous keys (either pk or fk) :
  * keys are kept in a cache specific to the field
  * this cache can not be accessed by any means so no clear
      is possible
  * this cache can not be a per-broker cache
  * anonymous persistent fields implementation
      can not be extended or overriden

I'm willingfull to help refactoring this part, but i'd like to
have guidelines on how to do it...
I think it would be great
if anonymous keys are integrated within the existing cache system,
but i have no ideas on how to do it.

Guillaume


-----Message d'origine-----
De : Brian McCallister [mailto:mccallister@forthillcompany.com]
Envoyé : jeudi 22 avril 2004 14:06
À : OJB Users List
Objet : Re: Problem with clearing cache


Anonymous PK's are risky things -- I apologize for using them in the
original anonymous keys tutorial. Anonymous FK's are great, and not
using them is usually a bad ida in my opinion =)

I don't think the anonymous PK issues you are having will be resolved
very soon, the anonymous key functionality wasn't really designed for
PK usage, but for FK usage. I completely feel that it would be good to
be able to use them for PK's as well, but my slate is full at the
moment with JDO stuff =(

I don't know about everyone else. Any chance *you* want to dig into it?
;-)

-Brian

On Apr 22, 2004, at 7:55 AM, Guillaume Nodet wrote:

> It also seems that cached anonymous keys are not removed from
> the cache when an object is deleted from database.
> Will these problems be solved, or should i try not to use
> anonymous keys ?
>
> Guillaume
>
> -----Message d'origine-----
> De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
> Envoyé : mercredi 21 avril 2004 14:42
> À : OJB Users List
> Objet : Problem with clearing cache
>
>
> I need to clear the ojb cache at some point in my program
> (namely after deleting all data in the database).
> The problem i have is that i use anonymous primary keys and
> the caches associated with the anonymous fields are not cleared.
> Would it be possible to had some mean of clearing these caches ?
>
> The problem is that at some time, i've got errors when inserting
> objects. I think that the key for the failing object is in cache
> but not in the database so when a foreign key references it,
> the insertion fails.
>
> Thanks,
> Guillaume Nodet
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with clearing cache

Posted by Brian McCallister <mc...@forthillcompany.com>.
Anonymous PK's are risky things -- I apologize for using them in the 
original anonymous keys tutorial. Anonymous FK's are great, and not 
using them is usually a bad ida in my opinion =)

I don't think the anonymous PK issues you are having will be resolved 
very soon, the anonymous key functionality wasn't really designed for 
PK usage, but for FK usage. I completely feel that it would be good to 
be able to use them for PK's as well, but my slate is full at the 
moment with JDO stuff =(

I don't know about everyone else. Any chance *you* want to dig into it? 
;-)

-Brian

On Apr 22, 2004, at 7:55 AM, Guillaume Nodet wrote:

> It also seems that cached anonymous keys are not removed from
> the cache when an object is deleted from database.
> Will these problems be solved, or should i try not to use
> anonymous keys ?
>
> Guillaume
>
> -----Message d'origine-----
> De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
> Envoyé : mercredi 21 avril 2004 14:42
> À : OJB Users List
> Objet : Problem with clearing cache
>
>
> I need to clear the ojb cache at some point in my program
> (namely after deleting all data in the database).
> The problem i have is that i use anonymous primary keys and
> the caches associated with the anonymous fields are not cleared.
> Would it be possible to had some mean of clearing these caches ?
>
> The problem is that at some time, i've got errors when inserting
> objects. I think that the key for the failing object is in cache
> but not in the database so when a foreign key references it,
> the insertion fails.
>
> Thanks,
> Guillaume Nodet
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Problem with clearing cache

Posted by Guillaume Nodet <gu...@deliasystems.com>.
It also seems that cached anonymous keys are not removed from
the cache when an object is deleted from database.
Will these problems be solved, or should i try not to use
anonymous keys ?

Guillaume

-----Message d'origine-----
De : Guillaume Nodet [mailto:guillaume.nodet@deliasystems.com]
Envoyé : mercredi 21 avril 2004 14:42
À : OJB Users List
Objet : Problem with clearing cache


I need to clear the ojb cache at some point in my program
(namely after deleting all data in the database).
The problem i have is that i use anonymous primary keys and
the caches associated with the anonymous fields are not cleared.
Would it be possible to had some mean of clearing these caches ?

The problem is that at some time, i've got errors when inserting
objects. I think that the key for the failing object is in cache
but not in the database so when a foreign key references it,
the insertion fails.

Thanks,
Guillaume Nodet

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org