-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Can this mapping be done?
PostPosted: Wed Apr 20, 2005 4:35 am 
Newbie

Joined: Wed Apr 20, 2005 4:14 am
Posts: 10
Location: Netherlands
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?


Top
 Profile  
 
 Post subject: Mapping
PostPosted: Wed Apr 20, 2005 7:27 am 
Beginner
Beginner

Joined: Wed Apr 21, 2004 8:33 am
Posts: 27
I guess you need not define the mapping to your Status-Info Table.
Instead you can Iterate through your Objects(10) and just save them to the Subject Table where the object ID Generated is the Priamry Key if i am not wrong and the Status-indo ID will anyway have a foreign-key reference to Status-Info table and the Other ObjectKind Id can also be saved.
Only when you try to retreive you can define a mapping to the table Probably Set with One to Many
I dont know if my reply makes sense, Whatever i understood from your problem that was my solution
Sorry if am wrong
Thanks and Rgds


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 25, 2005 9:15 am 
Newbie

Joined: Wed Apr 20, 2005 4:14 am
Posts: 10
Location: Netherlands
I'm done with this. I just used a <map ...> All done now :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.