Hi all,

I would like to report some problems I had to map two sister classes on the same table, and make sure I am not doing anything wrong. I am using the ODMG API, OJB RC4 with j2sdk1.4.1_01 on windows, and MySQL 4.

I followed the "Advanced O/R" tutorial, chapter "Mapping all classes on the same table".
I chose to use a column of the table in which I had INT values as the selector for the class, so, as stated in the doc:
-> created my own RowReader extending RowReaderDefaultImpl, overwrote selectClassDescriptor()
-> declared the row reader in the class descriptor
-> declared the ojbConcreteClass field in a <field-descriptor> element


I then spawned my program (oqlQuery = "select reservations from " + MyClass.class.getName() + " where ( status = \"init\" or status = \"comp\" ) and endDate > $1") and got the following exception:
java.sql.SQLException: Cannot convert class java.lang.String to SQL type requested due to java.lang.NumberFormatException - For input string: "(FQCN of MyClass)"


_Hours_ later... :-( , I tried to change the class selector field name from "ojbConcreteClass" to something else ("typeRessource" for example), because I figured out "ojbConcreteClass" was some kind of voodoo thing: my selectClassDescriptor() method was never called, so I could not even use my debugger for tracking the problem down.
There, I got a different exception, which looked better for me because "typeRessource" was not a property of MyClass:
java.lang.NoSuchFieldException: typeRessource [...snip...] rethrown as org.apache.ojb.broker.metadata.MetadataException: Can't find member typeRessource in (FQCN of MyClass): typeRessource


I remembered that I gave a try at anonymous fields some weeks ago; my concern at that time was about hiding primary key fields from my model; I tried to apply them to my class selector field:
<field-descriptor name="typeRessource" column="TYPERESSOURCE" jdbc-type="INTEGER" access="anonymous" />


And my program is working now :-)

This situation looks like a well known one because, after a search for the "ojbConcreteClass" pattern in the source file hierarchy, I noticed from the comments in the AnonymousPersistentField class that anonymous fields can be applied to (were designed for ?) fields used for selecting classes. But the anonymous fields HOWTO only deals with primary key fields, and does not mention its use with class selector fields.

So, do the docs have to be refreshed, did I miss something, or did something wrong?

Thanks for reading so far

PS: just a last point: debugging messages in JdbcAccessImpl are quite difficult to understand, I spent a long time staring at the following message (just before the SQLException), while there was nothing traced in P6SPY log:
DEBUG [main] accesslayer.JdbcAccessImpl - executeQuery : Query from class (FQCN of MyClass) where [EMAIL PROTECTED]
Is there a mean to dump Criteria in the log ?



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



Reply via email to