Does it make a different if you remove the
attribute-override for country code and map as follows?
<embeddable class="com.model.Location">
<attributes>
<basic name="address" attribute-type="java.lang.String"/>
<basic name="countryCode" attribute-type="java.lang.String">
<column name="COUNTRY_CODE" insertable="false" updatable="false" />
</basic>
</attributes>
</embeddable>
<entity class="com.model.Employee">
<attributes>
<basic name="country" attribute-type="java.lang.String">
<column name="COUNTRY_CODE" insertable="true" updatable="true"/>
</basic>
<embedded attribute-type="com.model.Location" name="workLocation">
<attribute-override name="address">
<column name="WORK_ADDR"/>
</attribute-override>
</embedded>
<embedded attribute-type="com.model.Location" name="homeLocation">
<attribute-override name="address">
<column name="HOME_ADDR"/>
</attribute-override>
</embedded>
</entity>
Cheers,
Guy
On 29/10/2012 8:21 AM, bhakti b wrote:
Consider the following sample case
Embeddable class declared as follows :
<embeddable class="com.model.Location">
<attributes>
<basic name="address" attribute-type="java.lang.String"/>
<basic name="countryCode" attribute-type="java.lang.String">
<column insertable="false" updatable="false" />
</basic>
</attributes>
</embeddable>
The Embedded attributes used in the entity as follows:
<entity class="com.model.Employee">
<attributes>
<basic name="country" attribute-type="java.lang.String">
<column name="COUNTRY_CODE" insertable="true" updatable="true"/>
</basic>
<embedded attribute-type="com.model.Location" name="workLocation">
<attribute-override name="address">
<column name="WORK_ADDR"/>
</attribute-override>
<attribute-override name="countryCode">
<column name="COUNTRY_CODE" />
</attribute-override>
</embedded>
<embedded attribute-type="com.model.Location" name="homeLocation">
<attribute-override name="address">
<column name="HOME_ADDR"/>
</attribute-override>
<attribute-override name="countryCode">
<column name="COUNTRY_CODE" />
</attribute-override>
</embedded>
...
</entity>
When trying to persist the above entity, we have set the value for attribute
“country” ,the value for COUNTRY_CODE is being inserted as null.
Is there some problem with the way the embeddable class is being used ?
Employee e = new Employee();
e.setCountry("AUS");
e.setWorkLocation(new Location("111 ABC", "AUS"));
e.setHomeLocation(new Location("112 XYZ", "AUS"))
Essentially the requirement is that the same column name has to be used when
mapping the embedded attribute.
--
View this message in context: http://eclipse.1072660.n5.nabble.com/Is-there-a-way-by-which-we-can-map-the-same-column-to-multipe-embedded-attribute-overrides-tp155354.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--

Guy Pelletier
ORACLE Canada,
45 O'Connor Street
Suite 400
Ottawa, Ontario
Canada K1P 1A4
Oracle is committed to developing
practices and products that help protect the environment