[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proxy objects
hello guys
I may have a problem;
the context:
I store PersistentFacts(extends OzoneObject) in a HashMap of Lists.
here is a code extract from my application:
this is not working:
Object[] objects = factsMap.get(factType);
return (PersistentFact[])objects;
(throws a ClassCastException at the last line)
whereas this is working;
Object[] objects = factsMap.get(factType);
PersistentFact fact = (PersistentFact)objects[0];
PersistentFact[] facts = new PersistentFact[1];
facts[0] = fact;
return (PersistentFact[])objects;
could someone explain me why it is possible?
At 14:06 11/06/2001 +0200, you wrote:
>On Mon, 11 Jun 2001, Stan Pinte wrote:
> > hello,
> >
> > I have a question which doesn't seen to be documented:
> >
> > I have a database object (extending OzoneObject), which contains a
> HashMap,
> > which contains Vectors, which contains other Database objects (extending
> > OzoneObject).
> >
> > Am I authorized to do this? I have the feeling that the HashMap and the
> > Vectors will have to be more or less "database-aware"...
>
>This should work without problems. The database objects which are stored
>in the
>HashMap are proxies in reality. This is all the database wareness you need.
>
>There are pitfalls with the use of java2 collections however. One is that you
>cannot give an iterator of such a Collection to the outside of the datbase
>object that it belongs to. We discussed this some time ago. Anyway, IMO you
>should go ahead writing your code and come back with concrete
>questions/problems when they actually arise.
>
>
>Falko
>--
>______________________________________________________________________
>Falko Braeutigam mailto:falko@smb-tec.com
>SMB GmbH http://www.smb-tec.com