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.
         doSet(PersistentFieldDirectAccessImpl.java:88)
  at org.apache.ojb.broker.metadata.fieldaccess.AbstractPersistentField.
         set(AbstractPersistentField.java:99)
...
Caused by: java.lang.IllegalArgumentException
  at sun.reflect.UnsafeObjectFieldAccessorImpl.
         set(UnsafeObjectFieldAccessorImpl.java:63)
  at java.lang.reflect.Field.set(Field.java:519)
...

2. I use the XDoclet module and the documentation of it claims that:
http://db.apache.org/ojb/docu/guides/xdoclet-module.html#ojb.collection:
"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
necessary."

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

3. This error was reported repeatedly:
http://www.mail-archive.com/ojb-user@db.apache.org/msg03124.html
(without reaction)
http://www.mail-archive.com/ojb-user@db.apache.org/msg03153.html
(same person again with useless reaction)
http://www.mail-archive.com/ojb-user@db.apache.org/msg04047.html
(don't know what the reaction shall mean)
http://www.mail-archive.com/ojb-user@db.apache.org/msg03299.html

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
ManageableCollection?

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.

Joerg


---------------------------------------------------------------------
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