简体   繁体   English

在ADF中更新子实体对象时,如何更新父实体对象?

[英]How do I update the parent Entity Object when updating the child Entity Object in ADF?

I finished the JDeveloper Cue Card "Build a Fusion Web Application" which is pretty basic and shows you have to update a parent( ORDER ) table and view the child ( ORDER_ITEM ) rows associated with the parent record. 我完成了JDeveloper提示卡“构建Fusion Web应用程序”,这是非常基础的,它显示您必须更新一个父表(ORDER)表并查看与父记录关联的子行(ORDER_ITEM)。 This is all fine but of course in the "real world" you would need to update/add items to an order. 一切都很好,但是当然在“现实世界”中,您需要更新/添加订单中的项目。 Naturally after add/updating the ORDER_ITEMS table you would want the ORDER_TOTAL value in the ORDER table to reflect the change. 自然地,在添加/更新ORDER_ITEMS表之后,您希望ORDER表中的ORDER_TOTAL值能够反映更改。 In other words, if you double the quantity of one of the items, the ORDER_TOTAL value in the ORDER table should increase. 换句话说,如果您将其中一项的数量加倍,则ORDER表中的ORDER_TOTAL值应增加。

So to expand on the Cue Card, I added another page which allows me to update the values in the ORDER_ITEMS table which works fine - this is just out-of-the-box ADF magic. 因此,为了扩展Cue卡,我添加了另一个页面,该页面允许我更新ORDER_ITEMS表中的值,该表可以正常工作-这只是开箱即用的ADF魔术。

I tried to post an image of my task flow but my reputation level isn't high enough. 我尝试发布任务流程的图像,但是我的信誉水平不够高。 I guess I have to play the game longer to earn more guild points :) Here's a link to a picture click here I originally posted this question to the Oracle User Group but got no responses so I thought I would try this forum. 我想我必须玩更长的游戏才能获得更多的公会积分:)这是指向图片的链接。 单击此处, 我最初将此问题发布到Oracle用户组,但未得到任何回应,所以我想尝试这个论坛。

I tried two ways to update the ORDER_TOTAL in the ORDER table after an add/update to ORDER_ITEM table. 在向ORDER_ITEM表添加/更新之后,我尝试了两种方法来更新ORDER表中的ORDER_TOTAL。

1) Modify the orderview to include a nested select statement which calculates the ORDER_TOTAL dynamically 1)修改订单视图以包含嵌套的选择语句,该语句动态地计算ORDER_TOTAL

SELECT Orders.ORDER_ID,
       Orders.ORDER_DATE,
       Orders.ORDER_SHIPPED_DATE,
       Orders.ORDER_STATUS_CODE,
      (select sum(unit_price * quantity) from order_items a 
        where a.order_id = Orders.order_id
       group by order_id )
AS ORDER_TOTAL, 
       Orders.CUSTOMER_ID, 
       Orders.SHIP_TO_NAME,
       Orders.SHIP_TO_ADDRESS_ID,
       Orders.SHIP_TO_PHONE_NUMBER,

. . . .

2) Add an update to the ORDER_TOTAL value in the ORDER table with in the task flow after an add/update to ORDER_ITEM table and COMMIT. 2)在对ORDER_ITEM表和COMMIT添加/更新之后,在任务流中向ORDER表中的ORDER_TOTAL值添加更新。

update orders set order_total = ???? 更新订单设置order_total = ???? where order_id = ???? 其中order_id = ????

With either solution, I get the same results which is as follows 无论使用哪种解决方案,我都会得到如下相同的结果

I update the ORDER_ITEM table in the editOrderItem.jsff page, the task flow performs a COMMIT and returns to the editOrder.jsff page, ORDER_TOTAL amount does not reflect the change. 我在editOrderItem.jsff页中更新了ORDER_ITEM表,任务流执行了一次COMMIT并返回到editOrder.jsff页,ORDER_TOTAL的金额不反映更改。 Hitting cancel from editOrder.jsff returns to order.jsff which show the correct ORDER_TOTAL amount. 从editOrder.jsff中单击cancel将返回到order.jsff,其中显示了正确的ORDER_TOTAL金额。 Returning to editOrder.jsff from order.jsff and the correct value for ORDER_TOTAL appears. 从order.jsff返回到editOrder.jsff,并显示正确的ORDER_TOTAL值。 It seems that the values in the ADF form inside order.jsff are cached and the page never refreshes against any updates to the database. 似乎order.jsff内的ADF表单中的值已缓存,并且该页面从不针对数据库的任何更新刷新。 I've tried to make editOrder.jsff refresh by changing the properties from refresh "true" to "false". 我试图通过将属性从刷新“ true”更改为“ false”来使editOrder.jsff刷新。 Also changed CacheResults from "true" to "false". 还将CacheResults从“ true”更改为“ false”。 Tried modifying the task flow properties from "no controller action" to "Always Begin New Transaction". 尝试将任务流属性从“无控制器动作”修改为“始终开始新事务”。

提交ORDER_ITEM修改后,您需要重新执行包含ORDER_TOTAL的查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Rails中,如何在加载子对象时自动加载父对象? - In Rails, how do I automatically load my parent object when the child object is loaded? php,我需要来自父母的子对象,怎么样? - php, I need child object from parent, how? 实体框架6向下多层添加子对象 - Entity Framework 6 Adding Child Object Several Layers Down 子 object 访问父 object 的更好方法? - Better way of child object accessing parent object? 我如何让所有孩子 <div> 一个孩子导致父级扩展时,s扩展到父级div的长度? - How do I make all child <div>s expand to the length of parent div when one child causes parent to expand? 为什么在初始化子对象并将其分配给父对象时调用父方法 - Why parent method is called when child object is initialized and assigned to a parent object 如何从子Slider movieclip访问父级中定义的对象 - How to access object defined in parent, from child Slider movieclip 如何在父母和孩子之间共享过滤后的对象数组 - How to share a filtered object array between parent and child's 在 iframe 中单击子页面时,如何将父页面滚动到顶部? - How do I Scroll parent page to top when child page is click within iframe? 在 iframe 中单击子页面时,如何将父页面滚动到 Hashtag? - How do I Scroll parent page to a Hashtag when child page is click within iframe?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM