`

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);
    }

}

 

 

分享到:
评论

相关推荐

    Overloading&Overriding

    Overloading&Overriding两者的区别

    Spring Boot: Bean definition overriding

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

    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 ...

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

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

    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,删除操作部分并保持路由清洁...

    VB.NET Developer's Guide(4574).pdf

    Exercise 3.4 Adding a New Toolbar to the Existing Set 136 Exercise 3.5 Adding Commands to Toolbars 137 Customizing Built-In Commands 137 Exercise 3.6 Creating an Alias 138 Customizing the Start ...

    C#学习的101个经典例子

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

    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 ...

    CSS for Windows 8 App Development

    CSS for Windows 8 App Development is your learning guide for CSS – the language of great Windows 8-style apps....Overriding and Defining Styles CSS Libraries and Resources Styling SVG

    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

    Interactive.Object.Oriented.Programming.in.Java

    This book uses Java and Eclipse to write and generate output for examples in topics such as classes, interfaces, overloading, and overriding. Interactive Object Oriented Programming in Java uniquely ...

    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-...

    Intermediate Perl.pdf

    Work with classes, method calls, inheritance, and overriding. Chapter 12, Objects with Data Add per-instance data, including constructors, getters, and setters. Chapter 13, Object Destruction Add ...

    Swift.OS.X.Programming.for.Absolute.Beginners.1484212347

    Swift OS X Programming for Absolute Beginners is your step-by-step guide to learning how to code using Swift, Apple's hottest new programming language. This book will not only teach complete ...

    微软内部资料-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 ...

    Method-Overloading-and-OverRiding.rar_OA系统_Java_

    Method Overloading and OverRiding

    cJSON-master.zip

    cJSON is written in ANSI C (C89) in order to support as many platforms and compilers as possible. #### CMake With CMake, cJSON supports a full blown build system. This way you get the most ...

    Python Cookbook英文版

    2.12 Sorting Objects Using SQL's ORDER BY Syntax 3. Text 3.1 Processing a String One Character at a Time 3.2 Testing if an Object Is String-Like 3.3 Aligning Strings 3.4 Trimming Space ...

Global site tag (gtag.js) - Google Analytics