-->
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: mapping subclass w/ discriminator, join table & one-to-one
PostPosted: Fri Oct 30, 2009 11:51 am 
Newbie

Joined: Fri Oct 30, 2009 11:41 am
Posts: 6
the following mapping is wrong because inside <subclass> it isn't allowed to have both <join table=""> and <one-to-one ... /> can someone hint me on the correct way to get this working ? I think it would work if i map both service types to diferent tables but i don't want to repeat the shared columns. Another way would be to have a two-step extension from GeographicService to GeographicServiceWfs and include the join in one step and the one-to-one in another step. But none of the solutions seem correct. Can you please suggest me something else?

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.sinfic.ipdms.domain.entity">
   <class name="GeographicService" table="GEOGRAPHIC_SERVICE" abstract="true">

      <id name="id" type="long" column="ID" unsaved-value="0">
         <generator class="native">
            <param name="sequence">GEOGRAPHIC_SERVICE_SEQUENCE</param>
         </generator>
      </id>

      <discriminator column="SERVICE_TYPE" type="string" />

      <property name="url" type="string" column="URL" />
      <property name="title" type="string" column="TITLE" />
      <property name="description" type="string" column="DESCRIPTION" />

      <subclass name="GeographicServiceWms" discriminator-value="WMS">
         <set name="layers" table="GEOGRAPHIC_LAYER" cascade="all">
            <key>
               <column name="GEOGRAPHIC_SERVICE_ID" />
            </key>   
            <one-to-many class="GeographicLayer" />
         </set>
      </subclass>

      <subclass name="GeographicServiceWfs" discriminator-value="WFS">
         <join table="GEOGRAPHIC_SERVICE_WFS">
            <key column="GEOGRAPHIC_SERVICE_ID" />
            <property name="defaultGraphic" type="string" column="DEFAULT_GRAPHIC" />
            <property name="temporaryGraphic" type="string" column="TEMPORARY_GRAPHIC" />
            <property name="deleteGraphic" type="string" column="DELETE_GRAPHIC" />
            <property name="currentGraphic" type="string" column="CURRENT_GRAPHIC" />
            <property name="highlightedGraphic" type="string" column="HIGHLIGHTED_GRAPHIC" />
            <property name="selectedGraphic" type="string" column="SELECTED_GRAPHIC" />
         </join>
         <one-to-one name="layer" property-ref="service" cascade="all" />
      </subclass>

   </class>
</hibernate-mapping>



Top
 Profile  
 
 Post subject: Re: mapping subclass w/ discriminator, join table & one-to-one
PostPosted: Mon Nov 02, 2009 7:33 am 
Newbie

Joined: Fri Oct 30, 2009 11:41 am
Posts: 6
Solved :) seems that changing the order of <join> and <one-to-one> resolves the problem, no more invalid mapping exception.

Code:
      <subclass ... >
         <join ...>
         <one-to-one ... />


didn't work but

Code:
      <subclass ... >
         <one-to-one ... />
         <join ...>

works...

Could this be a bug in the parser?


Top
 Profile  
 
 Post subject: Re: mapping subclass w/ discriminator, join table & one-to-one
PostPosted: Thu Nov 12, 2009 2:12 am 
Newbie

Joined: Wed Nov 04, 2009 11:50 am
Posts: 3
Thank you much for this advise. This helped a lot. I didnt imagine that this problem could be solved by just swapping the order.

Ramchander.


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.