Title: Why it is RelationCollection?

If I have two classes - A and B. A have a set of B (by collection).
B depends on A.

Becose class B depends on A, I can't use OQL and db.load per class B directly. But I have access to them via class A (a collection field).

But this mean that I can only add and removeAll methods. Other requered methods as removeById(Object id) getById(Object id) expected.

How I can remove item B from A collection by them id? Or how I can get B by id? Now I must iterate all collection to find B item equals to

specify id - and it break lazy loading conception, cos for method next Castor load full item.'

Maybe need a RelationHashMap? Or RelationList? But why Collection?

This method remove(Object o) from RelationCollection:
    public boolean remove(Object o) {
        Object id = _molder.getIdentity( _tx, o );
        boolean changed = false;

        if ( _deleted.contains( id ) )
            return false;

        if ( _added.contains( id ) ) {
            _added.remove( id );
            _changecount++;
            _size--;
            return true;
        } else if ( _ids.contains( id ) ) {
            _deleted.add( id );
            _changecount++;
            _size--;
            return true;
        }

        return false;
    }
How u see - Object as is I needed only for retrive it ID value. So method remove may be contain only id:
    public boolean removeById(Object id) {
        boolean changed = false;

        if ( _deleted.contains( id ) )
            return false;

        if ( _added.contains( id ) ) {
            _added.remove( id );
            _changecount++;
            _size--;
            return true;
        } else if ( _ids.contains( id ) ) {
            _deleted.add( id );
            _changecount++;
            _size--;
            return true;
        }

        return false;
    }

    public boolean remove(Object o) {
         Object id = _molder.getIdentity( _tx, o );
         return removeById(id);
    }

Resume - Conception with depends objects in Castor now unusible without id's access method to child objects.

Alexey Efimov - Software Engineer
Sputnik Labs
1st Kolobovsky per., 6/3
Moscow, 103051, Russia
Phone: +7 (095) 725 5444
Direct: +7 (501) 401 3217
Fax: +7 (095) 725 5443
E-Mail: mailto:[EMAIL PROTECTED]
http://www.spklabs.com
 

Reply via email to