You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Adam Griffiths <pu...@adam-griffiths.co.uk> on 2003/08/01 16:52:51 UTC

rc4 reference-descriptor name="super"

Hi,
I noticed that 1.0 rc4 is out, (although the front page of the site does not
mention it). It includes the addition of the special 'super' reference
descriptor for mapping classes on multiple joined tables. i.e:
<reference-descriptor name="super" ../>. I very am pleased to find this has
been added, it suits my mapping situation well.

It works fine for the simple cases given in the docs (tutorial3) but I have
two cases where I'm having trouble making it work. The first is when 'super'
is an abstract class and the second is when using 'extents'.

The error I get when the 'super' (test.A in my example) class is abstract
is: 

[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR:
PersistenceBrokerException during the execution of materializeObject: Unable
to build object instance (MAYBE you don't have a constructor
available):class test.A: (Could not instantiate test.A: null)

Which makes sense because test.A is abstract and could not be instantiated,
however it never needs to be because only it's subclasses are. It seems that
ojb wants to instantiate it all the same and I wondered if it would make a
good addition to ojb to not attempt to instantiate abstract classes,
specifically so that they can be used <reference-descriptor name="super"/>.

With extents the problem I encountered was as follows. It is does not work
to have  <!--extent-class class-ref="test.B" /--> in the <class-descriptor
class="test.A" table="A" >, in this case ojb returns all the A objects,
twice! As I was saying earlier I would like A to be abstract but even when
it's not this still does not make sense to return A objects when really the
rows in table A represent part B objects (by virtue of the fact their
primary key is in table B as a foreign key, and A is 'super' to B). My guess
is that the extent mechanism is designed for mapping all classes on the same
table, it would be great if it also worked for mapping classes on multiple
joined tables.

I'd be very grateful if someone could let me know if I'm misunderstanding
anything here, or if I'm encountering a bug / missing feature of the latest
OJB.

Many Thanks
Adam

I have attached a zip file with all the necessary java, settings files, and
sql script to set up the test cases that I used. If you want to play around
it should be fairly simple to use them.

________________________________________________________
s_p_a_m_t_r_a_p       from:ignoreme@adam-griffiths.co.uk
Do not email the above address or remove these two lines