Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Is there a way by which we can map the same column to multipe embedded attribute overrides ?

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.


Back to the top