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.