`

Overriding postChanges() to Control Post Order

 
阅读更多

错误: 

 

oracle.jbo.DMLConstraintException:

JBO-26048: Constraint "Td_Parent_Id_FK" violated during post operation:

"Insert" using SQL Statement

 

原因:

 

 When the TdChild row is inserted, the database complains that the value of its Td_Parent_ID foreign key doesn't correspond to any row in the TdParent table. 

This occurred because:

The code created the TdChild before the TdParent

TdChild and TdParent entity objects are associated but not composed

The DML operations to save the new entity rows is done in chronological order, so the new TdChild gets inserted before the new TdParent.

 

解决方法:

 

public class TdChildImpl extends EntityImpl {
    private static EntityDefImpl mDefinitionObject;
    
    @Override
    public void postChanges(TransactionEvent e) {
         if (getPostState() == STATUS_NEW ||
             getPostState() == STATUS_MODIFIED) {
             TdParentImpl tdParent= getTdParent();
           if (tdParent!= null) {
             if (tdParent.getPostState() == STATUS_NEW) {
               tdParent.postChanges(e);
             }
           }
         }    
        super.postChanges(e);
    }

}

 

 

分享到:
评论

相关推荐

    Spring Boot: Bean definition overriding

    在本文中,我将讨论棘手的Spring Boot bean定义覆盖机制。 为了使您对该主题更加清楚,让我们从小测验开始。请看下一个简单的例子。 因此,我们有2种配置,它们使用名称beanName实例化bean,在主应用程序中,我们仅...

    Overloading&Overriding

    "Overloading&Overriding" 在面向对象编程中,Overloading和Overriding是两个重要的概念,它们都是多态性的体现。下面我们将对这两个概念进行详细的解释。 1. 方法重载(Overloading) 方法重载是让类以统一的...

    control-rewrite.rar_control_重写控件

    这就是所谓的“控件重写”(Control Overriding)。标题“control-rewrite.rar_control_重写控件”提示我们这是一个关于控件重写的资源包,适用于初学者。描述中提到这个资料已经在Visual Studio 2008环境下测试过,...

    Softgroup Components.NET Subclass and Hook Objects v2.0.3870

    However, to wrap subclassing and hooking into virtual function overriding it is an obscure technique unknown to a large population of Windows programmers. This is unfortunate, because there are many ...

    simpledraw

    The line (link) object of the control is very flexible, and can be hook to other objects or connect them together. By the way, the control has also some methods for supporting Delphi's clipboard and...

    hapi-overriding:覆盖 HTTP 动词

    对于任何传入的 POST 请求,扩展函数检查路径是否以定义的操作名称之一(例如destroy )结尾。 如果是这样,它会将方法更改为相应的 HTTP 动词(例如DELETE )。 它还将更改请求的 url,删除操作部分并保持路由清洁...

    C#学习的101个经典例子

    #学习的101个经典例子,例子个个经典,涵盖C#的方方面面,带有说详尽的注释 Advanced - Multithreading - How-To Async Calls Advanced - Remoting - How-To TCP Remoting ...WinForms - Dynamic Control Creation

    Java入门与进阶设计第11章:继承与Overriding.ppt

    在Java入门与进阶设计第11章中,我们主要探讨了两个关键概念:继承(Inheritance)和覆盖(Overriding)。 首先,所有的Java对象都间接或直接地继承自`java.lang.Object`类,它是所有类的终极祖先。当你创建一个新...

    Android代码-A JUnit rule to easily override Dagger 2 objects

    Overriding an object managed by Dagger 2 is not easy, you need to define a TestModule and, if you want to inject your test object, a TestComponent. Using a DaggerMockRule it's possible to override ...

    java面试题英文版及其答案

    Method overriding allows a subclass to provide a different implementation for a method defined in its superclass, while method overloading involves having multiple methods with the same name but ...

    1Z0-811 Exam Guide to Have a Cakewalk in Oracle Java SE Certific

    - **Overloading and Overriding:** Learn about method overloading and overriding. 3. **Decision Statements:** - **If-Else Statements:** Master the use of if-else statements for conditional logic. -...

    Effective Java 3rd edition(Effective Java第三版英文原版)附第二版

    目录如下: 1 Introduction 2 Creating and Destroying Objects ...Item 89: For instance control, prefer enum types to readResolve Item 90: Consider serialization proxies instead of serialized instances

    PROFESSIONAL F# 2.0

    This chapter explains how to implement inheritance in F#, including overriding methods and accessing base class members. - **Generics (Chapter 10):** Generics provide a way to write type-safe code ...

    oop-java-overriding-davidlenner:oop-java-overriding-davidlenner由GitHub Classroom创建

    接口和抽象类是实现OOP中多态性的重要工具,而方法覆盖(Method Overriding)则是体现类继承和多态性的关键概念。在这个项目"oop-java-overriding-davidlenner"中,我们将深入探讨这三个主题。 首先,我们来看接口...

    oop-java-overriding-ereich1993:oop-java-overriding-ereich1993由GitHub Classroom创建

    方法覆盖(Method Overriding)是Java中多态性的重要体现,它允许子类对父类的方法进行重新定义,以实现特定的功能。本项目"oop-java-overriding-ereich1993"可能是一个教学资源,旨在帮助学习者理解这些概念并进行...

    Change Color of Component in Specific Display State Example

    to gray in the specified display state. This is the overriding color level. 4. Examine the component in the graphics area, then press F5. 5. Changes the selected component's, USB_cover1, part-...

    微软内部资料-SQL性能优化3

    It is up to the application to define what consistency means, and isolation in some form is needed to achieve consistent results. SQL Server uses locking to achieve isolation. Definition of ...

Global site tag (gtag.js) - Google Analytics