Dear readers, I am currently adapting an existing project to use hibernate 3 on Oracle 9. Hibernate is new to me but nonetheless I have the idea that the following situation might be impossible to implement.
I have about 10 different object (each with their own tables) that have a set of status-information-records. Status-information is stored in 1 table for all those different objects. The status-information is stored like this:
- ID (unique)
- ObjectID (the ID of the object this status-info belongs to)
- ObjectkindID (the ID of the object-kind, so that we know which one of the 10 different objects we're talking about)
- some other fields.
I've read the documentation, and I think I should use some construction like this for each object:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hiernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="geotax.core.Subject" table="SUBJECT">
<id name="id" column="ID" type="integer"> <generator class="increment"/> </id>
<property name=... />
<!-- here's the mapping to the status-information -->
<list name="statussen" table="BIB_STATUS">
<key column="OBJECTID"/>
<list-index column="ID"/>
<composite-element class="geotax.core.Status" formula="OBJECTKINDID=123" >
<property name="objectid" column="OBJECTID" type="integer"/>
<property name="objectkindid" column="OBJECTKINDID" type="integer"/>
<property name=.../>
</composite-element>
</list>
</class>
</hibernate-mapping>
However, this won't work as you might expect. It tells me the following:
Quote:
6570 [main] ERROR util.XMLHelper - Error parsing XML: XML InputStream(25) Element type "list-index" must be declared.
6570 [main] ERROR util.XMLHelper - Error parsing XML: XML InputStream(26) Attribute "formula" must be declared for element type "composite-element".
6580 [main] ERROR util.XMLHelper - Error parsing XML: XML InputStream(33) The content of element type "list" must match "(meta*,(cache|jcs-cache)?,key,index,(element|one-to-many|many-to-many|composite-element|many-to-any))".
org.hibernate.MappingException: Error reading resource: geotax/core/Subject.hbm.xml
So, obviously the code above is invalid.
I'd like you to ask for help about how to implement these status-information objects. Should I make a mapping like the one above for all 10 objects or just one for a status-object which i refer to in all other mapping files?
Or (I don't like this one) should I change my datamodel and create a different status-table for each object?