Updating with more information...

I have a class:

public class DatedList extends ArrayList {
        // a few new methods
}

I have another class:

public class AccountTeam {
        // my collections
        private DatedList salesReps = new DatedList();
        private DatedList accountManagers = new DatedList();
        private DatedList accountRelationsAssociates = new DatedList();

        // More attributes and methods
}

This is my mapping document:

        <class-descriptor
 
class="com.lmig.pm.affinity.model.client.account.AccountTeam"
        >
        <collection-descriptor
                name="accountManagers"
        
element-class-ref="com.lmig.pm.affinity.model.client.account.AccountMana
ger"
                auto-update="true"
        >
                <inverse-foreignkey field-ref="accountTeamId" />
        </collection-descriptor>

        ... more fields/collections
        </class-descriptor>

I can persist the objects just fine like this.  However when I retrieve
the object I get the following error:

[5/17/05 15:38:14:182 CDT] 1ce4da30 SystemOut     O [PersistentField]
ERROR: while set field: 
[try to set 'object value' in 'target object'
target obj class: com.lmig.pm.affinity.model.client.account.AccountTeam
target field name: accountRelationsAssociates
target field type: class com.lmig.pm.affinity.util.DatedList
target field declared in:
com.lmig.pm.affinity.model.client.account.AccountTeam
object value class:
org.apache.ojb.broker.util.collections.RemovalAwareCollection
object value: [null(N1000000)]
]
[5/17/05 15:38:14:203 CDT] 1ce4da30 SystemErr     R
org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error
setting field:accountRelationsAssociates in
object:com.lmig.pm.affinity.model.client.account.AccountTeam

So I figured I could redefine my collections like this:


        private List accountManagers = new DatedList();
        private List accountRelationsAssociates = new DatedList();
        private List salesReps = new DatedList();

This way also persists fine, but new I get this error when retrieving
the objects from the database.


[5/17/05 15:45:30:910 CDT] 3f081a3b SystemErr     R
java.lang.ClassCastException:
org.apache.ojb.broker.util.collections.RemovalAwareCollection


I'm assuming this is because OJB is creating the Collection as something
that can't be cast to a DatedList.  So then I changed DatedList so that
it implements IRemovalAwareCollection.  But that still results with the
same error as above.

I then tried adding:
collection-class="com.lmig.pm.affinity.util.DatedList" to the
collection-descriptors for the 3 collections in the AccountTeam
class-descriptor (while defining them as DatedList's instead of Lists in
the class) and I get this error:

[5/17/05 15:58:09:361 CDT] 51d19d89 SystemErr     R
org.apache.ojb.broker.OJBRuntimeException: Can't create new Collection
for owner

How do I get OJB to use my DatedList collections?

         -----Original Message-----
        From:   Lemke, Wesley  
        Sent:   Tuesday, May 17, 2005 2:35 PM
        To:     'OJB Users List'
        Subject:        Using user defined Collections

        We needed to extend the java.util.ArrayList class for a few of
our collections.  The objects persist fine, but I am getting class cast
exceptions when I try to retrieve the objects:

        java.lang.ClassCastException:
org.apache.ojb.broker.util.collections.RemovalAwareCollection

        Because we are subclassing from ArrayList, I didn't think that
we would need to use the collection-class attribute of the
collection-descriptor or implement ManageableCollection.  Is this true?

        What do I have to do, to use a subclass of ArrayList for my
collections?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to