-->
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.  [ 4 posts ] 
Author Message
 Post subject: StackOverflowError
PostPosted: Wed May 05, 2004 4:07 am 
Beginner
Beginner

Joined: Tue Mar 30, 2004 5:54 am
Posts: 22
Location: Bangalore
Can I map a Set inside a joined-subclass? Is this mapping right?

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

<hibernate-mapping>
    <class name="com.domain.ectd.budgets.Budget" table="BPMS_BUDGETS">
       <id name="budgetId" column="BUDGET_ID" length="32" unsaved-value="null">
          <generator class="uuid.hex" />
       </id>
       <property name="budgetType" column="BUDGET_TYPE"/>
       <property name="budgetYear" column="BUDGET_YEAR"/>
      <property name="isApproved" column="IS_APPROVED"/>
      <property name="costType" column="COST_TYPE"/>
      <property name="quarter" column="QUARTER"/>
      <property name="budgetAmount" column="BUDGET_AMOUNT"/>
       <many-to-one name="organisation" column = "ORG_CODE"/>
       <many-to-one name="costElement" column="ELEMENT_ID"/>      
      
      <joined-subclass name="com.domain.ectd.labor.LaborItem" table = "BPMS_LABOR">
         <key column="BUDGET_ID"/>
           <property name="laborCost" column="LABOR_COST"/>
           <property name="laborCount" column="LABOR_COUNT"/>
      </joined-subclass>

      <joined-subclass name="com.domain.ectd.materials.MaterialItem" table = "BPMS_MATERIALS">
         <key column="BUDGET_ID"/>
           <property name="materialCost" column="MATERIAL_COST"/>
            <set name="requirments" cascade="all" inverse="true" lazy="false">
                <key column="REQUIRMENT_ID"/>
                <one-to-many class="com.domain.ectd.requirement.Requirments"/>
            </set>
      </joined-subclass>      

      <joined-subclass name="com.domain.ectd.invoices.InvoiceItem" table = "BPMS_INVOICES">
         <key column="BUDGET_ID"/>
           <property name="invoiceCost" column="INVOICE_COST"/>
            <set name="requirments" cascade="all" inverse="true" lazy="false">
                <key column="REQUIRMENT_ID"/>
                <one-to-many class="com.domain.ectd.requirement.Requirments"/>
            </set>           
      </joined-subclass>
    </class>
</hibernate-mapping>


I am getting StackOverflowError after adding the one-to-many Set named "requirements".

If not, will you please let me know what is the alternative solution for this kind of mapping?

_________________
Thanks
Irfani


Top
 Profile  
 
 Post subject: Re: StackOverflowError
PostPosted: Wed May 05, 2004 7:09 am 
Beginner
Beginner

Joined: Sat May 01, 2004 2:44 am
Posts: 32
Location: Brisbane, Australia
This might be a silly question, but have you mapped the Requirements class? Its not there in the sample code you gave.

Scott


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 08, 2004 1:57 am 
Beginner
Beginner

Joined: Tue Mar 30, 2004 5:54 am
Posts: 22
Location: Bangalore
Scott

Yes, I do have the requirement classed mapped in a seprate file ... here is the mapped file.

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

<hibernate-mapping>
    <class name="com.domain.ectd.requirement.Requirments" table="BPMS_REQ_SPECS">
        <id name="requirementId" column="REQUIREMENT_ID" length="32" unsaved-value="null">
            <generator class="uuid.string"/>
        </id>
        <property name="description" column="REQ_DESCRIPTION"/>
        <property name="contractNo" column="REQ_CONTRACT_NO"/>
    </class>
</hibernate-mapping>
<!-- parsed in 0ms -->


In the first place, I want to know whether the mapping is right.

_________________
Thanks
Irfani


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 08, 2004 8:23 am 
Beginner
Beginner

Joined: Sat May 01, 2004 2:44 am
Posts: 32
Location: Brisbane, Australia
I'm guessing, but strongly, that the problem is that within your MaterialItem class mapping, the 'requirements' set element is marked with inverse="true". This means that Hibernate will not track changes (adds, removes) to the requirements set, because it is expecting that the Requirements class has a reference to the owning MaterialItem and will thus manage the link.

Try adding a property into Requirements that refers back to the owning MaterialItem, and add to the Requirments class mapping a many-to-one element for that property. Alternatively, remove the inverse="true" attribute from the set element .

Scott


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