-->
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: join and joined-subclass
PostPosted: Sat Apr 29, 2006 6:11 am 
Beginner
Beginner

Joined: Thu Jun 09, 2005 3:18 am
Posts: 34
Location: India
Hi

i am using Hibernate version 3

Here is my mapping file.


hibernate-mapping>
<class name="com.infozeal.tools.test.hibernate.Events" table="izdv.events">
<id name="id">
<generator class="increment"/>
</id>

<property name="eventName" column="EVENT_NAME"/>

<join table="IZDV.subevents">
<key column="id"/>
<property name="eName" column="ename"/>
</join>


<joined-subclass name="com.infozeal.tools.test.hibernate.ConferenceEvent" table="izdv.conf_event">
<key column="id"/>
<property name="seats"/>
</joined-subclass>

<joined-subclass name="com.infozeal.tools.test.hibernate.NetworkingEvent" table="izdv.net_event">
<key column="id"/>
<property name="foodName"/>
</joined-subclass>



</class>

</hibernate-mapping>

I am getting the following error
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array|query-list)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*)".
at weblogic.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:232)


My requirement is the fields which are in main class has to store in different tables when i save the subclass object.

It is working fine when i romove the <join>.

but for requirement i have to use join

Please help me.

thanks in advance


Top
 Profile  
 
 Post subject: <join> and <joined-subclass> : same problem
PostPosted: Wed Mar 21, 2007 10:31 am 
Newbie

Joined: Thu Mar 15, 2007 2:25 am
Posts: 6
Hi,
I am having the identical problem.

My base class is split between two tables (in order to handle dynamic internationalization of some base class properties) and I have two subclasses which are represented as two separate tables in the database.

This seems like it would be a pretty comon and resonable case?

Is there any reason why the DTD prevents all coexistences of <join> and <joined-subclass> elements within the parent <class>?

Please help with this or with a workaround if known...

Thanks,
Eric


Top
 Profile  
 
 Post subject: <join> and <joined-subclass> : solution
PostPosted: Wed Mar 21, 2007 1:19 pm 
Newbie

Joined: Thu Mar 15, 2007 2:25 am
Posts: 6
Ok,
Although you still cannot combine join and joined-sublass becasue it is prevented by the DTD, I have a workaround for this problem using <join> and <subclass>.

Basically, you combine the <join> and <subclass> with a discriminator, but "fake" the discriminator with a formula attribute.

So now, your hibernate mapping would look as follows:
(pay special attention to the <class> <discriminator> element and the discriminator attributes of the subclasses)

Code:
<hibernate-mapping>
   <class name="com.infozeal.tools.test.hibernate.Events" table="izdv.events">
      <id name="id">
         <generator class="increment"/>
      </id>

      <discriminator>
         <formula>
              CASE
                    WHEN (SELECT COUNT(*) FROM izdv.conf_event WHERE
      izdv.conf_event.id = id) > 0 THEN 'CONFERENCE'
                   ELSE 'NETWORKING'
                   END
         </formula>
      </discriminator>

      <property name="eventName" column="EVENT_NAME"/>
     
      <join table="IZDV.subevents">
         <key column="id"/>
         <property name="eName" column="ename"/>
      </join>

      <subclass name="com.infozeal.tools.test.hibernate.ConferenceEvent" discriminator-value="CONFERENCE">
         <join table="izdv.conf_event">
            <key column="id"/>
            <property name="seats"/>
         </join>
      <subclass>

      <subclass name="com.infozeal.tools.test.hibernate.NetworkingEvent" discriminator-value="NETWORKING">
         <join table="izdv.net_event">
            <key column="id"/>
            <property name="foodName"/>
         </join>
      <subclass>

</class>

</hibernate-mapping>


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.