[Teneo] Difficulty extending embeddable types [message #118703] |
Wed, 16 April 2008 15:57 |
Eclipse User |
|
|
|
Hello,
I'm having difficulty getting an extended embeddable type to map correctly.
I have an embeddable type, Address:
------------------------------------------------------------ ---------------------
<xsd:complexType name="Address">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Embeddable</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element default="" name="street1" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Address Street line 1
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element default="" name="street2" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Address Street line 2
</xsd:documentation>
</xsd:annotation>
</xsd:element>
.............................more elements................
</xsd:sequence>
</xsd:complexType>
------------------------------------------------------------ ---------------------
I then have a derived embeddable type, GeocodedAddress:
------------------------------------------------------------ ---------------------
<xsd:include schemaLocation="Address.xsd"/>
<xsd:complexType name="GeocodedAddress">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Embeddable</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="contact:Address">
<xsd:sequence>
<xsd:element name="longitude" type="xsd:double"/>
<xsd:element name="latitude" type="xsd:double"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
------------------------------------------------------------ ---------------------
I then try to embed the GeocodedAddress in another complex type:
------------------------------------------------------------ ---------------------
<xsd:element name="physicalAddress" type="contact:GeocodedAddress">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">
@Embedded
@AttributeOverrides({
@AttributeOverride(name="street1",
column=@Column(name="PHYSLN1_ADR")),
@AttributeOverride(name="street2",
column=@Column(name="PHYSLN2_ADR")),
.........more columns..........................
@AttributeOverride(name="longitude",
column=@Column(name="LONGITUDE")),
@AttributeOverride(name="latitude", column=@Column(name="LATITUDE"))
})
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
------------------------------------------------------------ ---------------------
When I try to read the object containing the physicalAddress property from
the database, it only serializes the GeocodedAddress information (latitude
and longitude), not the Address information (street1, 2, and others). The
Java classes appear to generate fine, with inheritence intact. I looked at
the generated hibernate mapping and it appears to simply not map the Address
fields:
------------------------------------------------------------ ---------------------
<component name="physicalAddress" class="contact.impl.GeocodedAddressImpl">
<property name="longitude" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="double">
<column not-null="false" unique="false" name="longitude"/>
</property>
<property name="latitude" lazy="false" insert="true" update="true"
not-null="false" unique="false" type="double">
<column not-null="false" unique="false" name="latitude"/>
</property>
</component>
------------------------------------------------------------ ---------------------
In the code excerpts above I've simplified the package structure slightly,
but no other changes were made. The Address class works fine on its own and
worked fine as a "PhysicalAddress" before I added the GeocodedAddress
extension. Am I configuring this correctly and approaching this problem in
an appropriate way?
Thanks for all the help and the great project!
-Alex
|
|
|
Powered by
FUDForum. Page generated in 0.02355 seconds