db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schmidt <clevers...@gmail.com>
Subject Mapping hierarchy in one table problem
Date Fri, 08 Feb 2008 12:32:54 GMT

Hi,

I'm facing a hard time trying to fix a problem in my app. Consider the
floowing class hierarchy:
class Project {..}
class ChildProject extends Project {..}
class GrandChildProject extends ChildProject {..}

All these classes are mapped to the same table: PROJECT_TABLE

Here are the mappings:

<class-descriptor table="PROJECT_TABLE" class="br.com.xxx.model.Project">
    <extent-class class-ref="br.com.xxx.model.ChildProject" />
    ...some fields here...
    <field-descriptor name="ojbConcreteClass" column="CLASS_NAME"
jdbc-type="VARCHAR" />
</class-descriptor>

<class-descriptor table="PROJECT_TABLE"
class="br.com.xxx.model.ChildProject">
    <extent-class class-ref="br.com.xxx.model.GrandChildProject" />
    ...some fields here...
    <field-descriptor name="ojbConcreteClass" column="CLASS_NAME"
jdbc-type="VARCHAR" />
</class-descriptor>

<class-descriptor table="PROJECT_TABLE"
class="br.com.xxx.model.GrandChildProject ">
    ...some fields here...
    <field-descriptor name="ojbConcreteClass" column="CLASS_NAME"
jdbc-type="VARCHAR" />
</class-descriptor>

Somehow when I search for GrandChildProject objects, OJB returns a
ChildProject reference. This ends up in a ClassCastException. Is there
anything wrong in the mappings or strategy used in this example?

Thanks in advance!
-- 
View this message in context: http://www.nabble.com/Mapping-hierarchy-in-one-table-problem-tp15354434p15354434.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.


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


Mime
View raw message