-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping a subclass containing bags using discriminator colum
PostPosted: Wed Oct 31, 2007 6:18 am 
Newbie

Joined: Wed Oct 31, 2007 6:04 am
Posts: 8
Location: Cologne, Germany
Hello all,

I'm currently experiencing problems mapping a bag inside a subclass which uses a discriminator.
This is my mapping:

Code:
<hibernate-mapping>
   <class name="com.gerig.bo.settlement.Agreement" table="AGREEMENTS">
      <id name="Id" column="ID" type="java.lang.Long">
         <generator class="sequence">
             <param name="sequence">agreements_seq</param>
         </generator>
      </id>      

      <discriminator column="TYPE" type="string"/>
[...]
      <subclass name="com.gerig.bo.settlement.LabelAgreement" discriminator-value="LabelAgreement">
         <join table="LABEL_AGREEMENTS">
            <key column="AGREEMENT_ID"/>
            <property name="AgreementMode" column="AGREEMENT_MODE"/>
         </join>
         <bag name="Recordings" cascade="none" inverse="false" table="LABEL_AGREEMENTS_RECORDINGS" lazy="false">
            <key column="AGREEMENT_ID" />
            <many-to-many column="RECORDING_ID" class="com.gerig.bo.label.Recording"/>
         </bag>
         <bag name="Productions" cascade="none" inverse="false" table="LABEL_AGREEMENTS_PRODUCTIONS" lazy="false">
            <key column="AGREEMENT_ID" />
            <many-to-many column="PRODUCTION_ID" class="com.gerig.bo.label.Production"/>
         </bag>
      </subclass>
   </class>
</hibernate-mapping>


The combination of <bag> and <subclass> elements leads to the following error:
Code:
The content of element type "subclass" must match
"(meta*,tuplizer*,synchronize*,(property|many-to-one|one-to-one|
component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-
array)*,join*,subclass*,loader?,sql-insert?,sql-update?,sql-delete?,resultset*,
(query|sql-query)*)".


Using <joined-subclass> will circumvent the issue, however, I need to use the discriminator value from the parent table.
I'd be grateful for any hints.
Would it maybe help to create a property for the type property and modify the getType() method to return class.getCanonicalName() ?

Best regards
Marcus


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2007 7:18 am 
Newbie

Joined: Wed Oct 31, 2007 6:04 am
Posts: 8
Location: Cologne, Germany
Well, I solved the problem. Type is now mapped to a String column and the getter always returns this.getClass().getSimpleName().
This way I can use joined-subclass and everything works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.