db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clute, Andrew" <Andrew.Cl...@osn.state.oh.us>
Subject RE: Problem with Inheritence: Get the wrong class back!
Date Thu, 11 Dec 2003 19:51:39 GMT
So, is that to say then if all of your objects inherit from a single base
object, then none of the objects can have the same primary key? They need to
be guids?

-Andrew



-----Original Message-----
From: Jakob Braeuchi [mailto:jbraeuchi@gmx.ch] 
Sent: Wednesday, December 10, 2003 2:55 PM
To: OJB Developers List
Subject: Re: Problem with Inheritence: Get the wrong class back!


hi andrew,

ojb requires a primary key to be _unique_ within a hierarchy defined in 
the repository.

jakob

Clute, Andrew wrote:

> So, say I have a concrete class named 'foo', and another concrete 
> class named 'bar' that extends foo.
> 
> In one instance of my code I do a QueryByIdentity for a class of type 
> 'foo' with a certain PK. This loads it into the cache with that 
> Identity.
> 
> Later on, I attempt to do a QueryByIdentity for the same PK, but this 
> time with the class 'bar' (and in this case, this is perfectly legal 
> casting) -- however, when OJB sees this PK in the cache, it returns 
> that object, and before it returns it all the way up it sees that foo 
> is not assignable to bar and throws a warning, and returns null.
> 
> So, in essence, I have a race condition -- if I first look for it with 
> the class being 'bar' it works great from then on using either 'foo' 
> or 'bar', but if I use 'foo' first, it is in the cache as 'foo' and 
> will never be returned as 'bar'.
> 
> Thoughts?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 


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

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


Mime
View raw message