Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Embeddables, association-override and cascade-merge

If you are getting an insert for currency, cascading is likely working. The issue seems to be that, for some reason, we do not know the Currency object you have created already exists.

To what degree does the Currency object actually exist? Does the insert result in a SQLException due to it's existence?

How is your persistence unit defined? Are you using any persistence unit properties related to caching or querying?

-Tom

On 28/02/2012 9:55 AM, sr_dd wrote:

Hello,

following problem:

i have defined an embeddable with mapping:
   <orm:embeddable class="Money">
     <orm:attributes>
       <orm:basic name="amount"/>
       <orm:many-to-one name="currency"  fetch="LAZY">
       	<orm:join-column column-definition="decimal" name="ID_CURRENCY"
referenced-column-name="ID"/>
       	<orm:cascade>
           <orm:cascade-merge />
         </orm:cascade>
       </orm:many-to-one>
     </orm:attributes>
   </orm:embeddable>
</orm:entity-mappings>

Currency is specified as follows:
   <orm:entity class="Currency">
     <orm:table name="SYSP.CURRENCY"/>
     <orm:attributes>
       <orm:id name="id">
         <orm:column name="ID"/>
       </orm:id>
       <orm:basic name="name">
         <orm:column name="NAME" nullable="false"/>
       </orm:basic>
...
     </orm:attributes>
   </orm:entity>

in another mapping i use the embeddable:
<orm:embedded name="airfreightRisk">
         <orm:attribute-override name="amount">
           <orm:column name="AIRFREIGHTRISK" nullable="true" />
         </orm:attribute-override>
         <orm:association-override name="currency">
           <orm:join-column name="ID_CURRENCY_AIRFREIGHTRISK" nullable="true"
referenced-column-name="ID" />
           <orm:cascade>
           <orm:cascade-merge />
         </orm:cascade>
         </orm:association-override>
       </orm:embedded>

In my CLF Test i create a new Entity and set the Attribute airfreightRisk
with a Money-Object which carries a loaded and already persisted
Currency-Object.

Trying to persist the new Entity brings me to the following problem:
* everything works fine staying attached.
* building the Object-Tree with detached Objects and merge the whole tree
results in an insert for currency
-->  the cascade-merge in embeddables seems not to work?!

Any ideas?

Stefan




Back to the top