-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping a Collection from a Nested Class
PostPosted: Thu Mar 08, 2007 3:38 pm 
Newbie

Joined: Thu Feb 08, 2007 4:43 pm
Posts: 7
Hibernate version: 3.2

I am trying to map java objects that were generated from an XML schema to tables in a database. The schema has a wrapper tag around its collections, so there are java objects that serve no other purpose than to hold a collection of other objects.

I have a class (FlightSegment, which is persisted) that contains a java object (Segment History, not persisted) with a collection of other objects (FlightDetail, which are persisted). SegmentHistory is a static inner class of FlightSegment, and FlightDetail is a static inner class of SegmentHistory. Here is a scaled down version of the class:

Code:
package mypackage;

class FlightSegment
{
   protected SegmentHistory segmentHistory;

   public SegmentHistory getSegmentHistory (){...}

   public void setSegmentHistory (SegmentHistory segmentHistory ){...}

   public static class SegmentHistory
  {
     protected List<FlightDetail> flightDetails;

     public static class FlightDetail
     {
         ...
     }
  }

}


I've tried using the component inside FlightSegment mapping:

Code:
<component name="segmentHistory" access="property">
   <bag name="flightDetail" access="field" cascade="save-update,persist">
      <key not-null="true">
         <column name="FLT_SEG_ID" />
      </key>
      <one-to-many class="FlightSegment$SegmentHistory$FlightDetail" />
   </bag>
</component>


From this mapping, I get the following exception:

[java] org.hibernate.MappingException: Unknown entity: mypackage.FlightSegment.mypackage.FlightSegment.segmentHistory

It seems to repeat the qualified class name before the field name.

I am trying to negotiate with the schema owner to drop the outer tags. If the schema cannot be changed, and I cannot accomplish this through mapping, I'll have to pull out the flight details and save them separately from flight segment.

I will be grateful for any help.


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

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.