db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject MetadataException when using Sets in 1:n relationships
Date Mon, 20 Dec 2004 16:51:29 GMT
Hello everybody,

do you remember me, the probably only person using OTM ;-)

When fixing an sorting bug in my application I switched an 1:n relationship from
List to Set. Unfortunately this does not work though the documentation says it
should as it is a Collection too. But step by step ...

1. The exception: org.apache.ojb.broker.metadata.MetadataException: Error
setting field:installmentRates in object:com.ewerk.erak.model.Settings
  at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImpl.
  at org.apache.ojb.broker.metadata.fieldaccess.AbstractPersistentField.
Caused by: java.lang.IllegalArgumentException
  at sun.reflect.UnsafeObjectFieldAccessorImpl.
  at java.lang.reflect.Field.set(Field.java:519)

2. I use the XDoclet module and the documentation of it claims that:
"collection-class: Specifies the class that implements the collection. This
attribute is usually only required if the actual type of the collection object
shall be different from the variable type. Collection classes that implement
java.util.Collection can be handled by OJB as-is so specifying them is not

So at least XDoclet module documentation is wrong or the module itself is broken.

3. This error was reported repeatedly:
(without reaction)
(same person again with useless reaction)
(don't know what the reaction shall mean)

4. I know OJB always instantiated a RemovalAwareCollection/List. So can it
handle my Set at all? It is not just a common Set, but my own class extending
java.util.TreeSet, providing a default constructor that instantiates a TreeSet
with a Comparator and providing all delegate methods that delegate to this
TreeSet. This means if OJB would use the constructors and methods of the
Collection interface everything should work.

5. Would just setting the collection-class help? Or do I need to implement

I have not tested all and everything like setting collection-class I have
somewhat longer release cycles at the moment (no direct access to a running
machine). I would be fine if you can answer the questions though.
Thanks for your help.


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

View raw message