自定义序列生成器会导致 'Too many objects match the primary key'

Will custom sequence generator cause 'Too many objects match the primary key'

我正在使用以下方法为我的 ADF 12c 应用程序生成一个序列。

     protected void doDML(int operation, TransactionEvent e) {
            if (operation == DML_INSERT) {
                SequenceImpl seq = new SequenceImpl("PATIENT_ID_SEQ", getDBTransaction());
                setPatientId(seq.getSequenceNumber().longValue());
            }
            super.doDML(operation, e);
        }

我有时会
与主键 oracle.jbo.Key[-1 ] 匹配的对象太多。

在 doDML 中填充 PK 属性发生 'too late'。在 ADF 中创建行后(按下 ADD 按钮的那一刻),您需要一个主键

您将需要这种方法: https://tompeez.wordpress.com/2011/09/02/using-groovy-expression-to-set-a-primary-key-with-a-sequence-number/