Insert / delete fails on unique constraint (order problem)

Hi dear Kodo team,
within a transaction, we are deleting a certain jdo object. The deletion is
undone later (within the same tx), resulting in creating a new object with
the same contents as the deleted one (gets another oid, of course). In our
database, there is a unique constraint on two mapped fields of this object.
Unfortunately, kodo issues the INSERT statement before the DELETE
statement, thus producing a unique constraint violation.
Is there a way to influence the statement order? Is there any solution other
than disabling / deferring this constraint?
Thanks in advance,
Contus

Beside Oracle, we are using our db schema on db platforms that do not
support deferred constraints. That's why we would like to know if there is
a way to influence statement order without removing those constraints.
Thanks,
Contus
Alex Roytman wrote:
In general the best option is to use deferred constraints on all your FK
and unique constraints. You still get complete referential integrity but
do not need Kodo to order your statements for you. If you are already
doing it but still get this error message and you are using Oracle 9.2 it
seems to be a bug in oracle JDBC. I submitted it to oracle - they accepted
it and supposedly working on resolution
"contus" <[email protected]> wrote in message
news:bulku6$qad$[email protected]..
Hi dear Kodo team,
within a transaction, we are deleting a certain jdo object. The deletionis
undone later (within the same tx), resulting in creating a new object
with the same contents as the deleted one (gets another oid, of course).
In our database, there is a unique constraint on two mapped fields of
thisobject.
Unfortunately, kodo issues the INSERT statement before the DELETE
statement, thus producing a unique constraint violation.
Is there a way to influence the statement order? Is there any solutionother
than disabling / deferring this constraint?
Thanks in advance,
Contus

Similar Messages

  • SIL_GLCOGSFact Failed with Unique Constraint

    Hi,
    A Task SIL_GLCOGSFact failed with ORA-00001: unique constraint (DW.W_GL_COGS_F_U1) violated
    while insert into table W_GL_COGS_F.
    There is not any record existing in the fact table. There is no way for such error. So weird.
    Please help me out.
    Roger
    Error in Session log as following:
    Database driver error...
    Function Name : Execute
    SQL Stmt : INSERT INTO W_GL_COGS_F(GL_ACCOUNT_WID,BUDGT_ORG_WID,CUSTOMER_WID,CUSTOMER_FIN_PROFL_WID,TERRITORY_WID,SALES_GROUP_ORG_WID,CUSTOMER_CONTACT_WID,CUSTOMER_SOLD_TO_LOC_WID,CUSTOMER_SHIP_TO_LOC_WID,CUSTOMER_BILL_TO_LOC_WID,CUSTOMER_PAYER_LOC_WID,SUPPLIER_WID,SUPPLIER_ACCOUNT_WID,SALES_REP_WID,SERVICE_REP_WID,ACCOUNT_REP_WID,PRODUCT_WID,SALES_PRODUCT_WID,INVENTORY_PRODUCT_WID,SUPPLIER_PRODUCT_WID,COMPANY_LOC_WID,PLANT_LOC_WID,SALES_OFC_LOC_WID,LEDGER_WID,COMPANY_ORG_WID,BUSN_AREA_ORG_WID,CTRL_AREA_ORG_WID,FIN_AREA_ORG_WID,SALES_ORG_WID,PURCH_ORG_WID,ISSUE_ORG_WID,DOC_TYPE_WID,CLRNG_DOC_TYPE_WID,POSTING_TYPE_WID,CLR_POST_TYPE_WID,COST_CENTER_WID,PROFIT_CENTER_WID,BANK_WID,PAY_TERMS_WID,TRANSACTION_DT_WID,TRANSACTION_TM_WID,CONVERSION_DT_WID,ORDERED_ON_DT_WID,INVOICED_ON_DT_WID,DELIVERED_ON_DT_WID,CUSTOMER_REQUEST_DT_WID,GOODS_ISSUE_DT_WID,STOCK_XFER_DT_WID,CLEARING_DOC_DT_WID,BASELINE_DT_WID,PLANNING_DT_WID,ACCOUNT_DOC_ID,COGS_DOC_AMT,COGS_LOC_AMT,XACT_QTY,UOM_CODE,DB_CR_IND,ACCT_DOC_NUM,ACCT_DOC_ITEM,ACCT_DOC_SUB_ITEM,CLEARING_DOC_NUM,CLEARING_DOC_ITEM,SALES_ORDER_NUM,SALES_ORDER_ITEM,SALES_SCH_LINE,INVOICE_NUM,INVOICE_ITEM,DELIVERY_DOC_NUM,DELIVERY_DOC_ITEM,GI_DOC_NUM,GI_DOC_ITEM,STO_DOC_NUM,STO_DOC_ITEM,DOC_HEADER_TEXT,LINE_ITEM_TEXT,ALLOCATION_NUM,FED_BALANCE_ID,BALANCE_ID,DOC_STATUS_WID,POSTED_ON_DT_WID,POSTED_ON_TM_WID,CLEARED_ON_DT_WID,GL_RECONCILED_ON_DT,DOC_CURR_CODE,LOC_CURR_CODE,LOC_EXCHANGE_RATE,GLOBAL1_EXCHANGE_RATE,GLOBAL2_EXCHANGE_RATE,GLOBAL3_EXCHANGE_RATE,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,DELETE_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,TENANT_ID,X_CUSTOM,GL_RECONCILED_ON_PROC_WID) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    Database driver error...
    Function Name : Execute Multiple
    SQL Stmt : INSERT INTO W_GL_COGS_F(GL_ACCOUNT_WID,BUDGT_ORG_WID,CUSTOMER_WID,CUSTOMER_FIN_PROFL_WID,TERRITORY_WID,SALES_GROUP_ORG_WID,CUSTOMER_CONTACT_WID,CUSTOMER_SOLD_TO_LOC_WID,CUSTOMER_SHIP_TO_LOC_WID,CUSTOMER_BILL_TO_LOC_WID,CUSTOMER_PAYER_LOC_WID,SUPPLIER_WID,SUPPLIER_ACCOUNT_WID,SALES_REP_WID,SERVICE_REP_WID,ACCOUNT_REP_WID,PRODUCT_WID,SALES_PRODUCT_WID,INVENTORY_PRODUCT_WID,SUPPLIER_PRODUCT_WID,COMPANY_LOC_WID,PLANT_LOC_WID,SALES_OFC_LOC_WID,LEDGER_WID,COMPANY_ORG_WID,BUSN_AREA_ORG_WID,CTRL_AREA_ORG_WID,FIN_AREA_ORG_WID,SALES_ORG_WID,PURCH_ORG_WID,ISSUE_ORG_WID,DOC_TYPE_WID,CLRNG_DOC_TYPE_WID,POSTING_TYPE_WID,CLR_POST_TYPE_WID,COST_CENTER_WID,PROFIT_CENTER_WID,BANK_WID,PAY_TERMS_WID,TRANSACTION_DT_WID,TRANSACTION_TM_WID,CONVERSION_DT_WID,ORDERED_ON_DT_WID,INVOICED_ON_DT_WID,DELIVERED_ON_DT_WID,CUSTOMER_REQUEST_DT_WID,GOODS_ISSUE_DT_WID,STOCK_XFER_DT_WID,CLEARING_DOC_DT_WID,BASELINE_DT_WID,PLANNING_DT_WID,ACCOUNT_DOC_ID,COGS_DOC_AMT,COGS_LOC_AMT,XACT_QTY,UOM_CODE,DB_CR_IND,ACCT_DOC_NUM,ACCT_DOC_ITEM,ACCT_DOC_SUB_ITEM,CLEARING_DOC_NUM,CLEARING_DOC_ITEM,SALES_ORDER_NUM,SALES_ORDER_ITEM,SALES_SCH_LINE,INVOICE_NUM,INVOICE_ITEM,DELIVERY_DOC_NUM,DELIVERY_DOC_ITEM,GI_DOC_NUM,GI_DOC_ITEM,STO_DOC_NUM,STO_DOC_ITEM,DOC_HEADER_TEXT,LINE_ITEM_TEXT,ALLOCATION_NUM,FED_BALANCE_ID,BALANCE_ID,DOC_STATUS_WID,POSTED_ON_DT_WID,POSTED_ON_TM_WID,CLEARED_ON_DT_WID,GL_RECONCILED_ON_DT,DOC_CURR_CODE,LOC_CURR_CODE,LOC_EXCHANGE_RATE,GLOBAL1_EXCHANGE_RATE,GLOBAL2_EXCHANGE_RATE,GLOBAL3_EXCHANGE_RATE,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,DELETE_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,TENANT_ID,X_CUSTOM,GL_RECONCILED_ON_PROC_WID) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    WRITER_1_*_1> CMN_1761 Timestamp Event: [Tue Nov 17 18:50:31 2009]
    WRITER_1_*_1> WRT_8425 ERROR: Writer execution failed.
    WRITER_1_*_1> CMN_1761 Timestamp Event: [Tue Nov 17 18:50:31 2009]
    WRITER_1_*_1> WRT_8114
    Row # [1] in bad file
    WRITER_1_*_1> CMN_1053 : Rowdata: ( RowType=0(insert) Src Rowid=42 Targ Rowid=42
    GL_ACCOUNT_WID (GL_ACCOUNT_WID:Double:): "271134.0000000000"
    BUDGT_ORG_WID (BUDGT_ORG_WID:Double:): "0.00000000000000"
    CUSTOMER_WID (CUSTOMER_WID:Double:): "0.00000000000000"
    CUSTOMER_FIN_PROFL_WID (CUSTOMER_FIN_PROFL_WID:Double:): "0.00000000000000"
    TERRITORY_WID (TERRITORY_WID:Double:): "0.00000000000000"
    SALES_GROUP_ORG_WID (SALES_GROUP_ORG_WID:Double:): "0.00000000000000"
    CUSTOMER_CONTACT_WID (CUSTOMER_CONTACT_WID:Double:): "0.00000000000000"
    CUSTOMER_SOLD_TO_LOC_WID (CUSTOMER_SOLD_TO_LOC_WID:Double:): "0.00000000000000"
    CUSTOMER_SHIP_TO_LOC_WID (CUSTOMER_SHIP_TO_LOC_WID:Double:): "0.00000000000000"
    CUSTOMER_BILL_TO_LOC_WID (CUSTOMER_BILL_TO_LOC_WID:Double:): "0.00000000000000"
    CUSTOMER_PAYER_LOC_WID (CUSTOMER_PAYER_LOC_WID:Double:): "0.00000000000000"
    SUPPLIER_WID (SUPPLIER_WID:Double:): "0.00000000000000"
    SUPPLIER_ACCOUNT_WID (SUPPLIER_ACCOUNT_WID:Double:): "0.00000000000000"
    SALES_REP_WID (SALES_REP_WID:Double:): "0.00000000000000"
    SERVICE_REP_WID (SERVICE_REP_WID:Double:): "0.00000000000000"
    ACCOUNT_REP_WID (ACCOUNT_REP_WID:Double:): "0.00000000000000"
    PRODUCT_WID (PRODUCT_WID:Double:): "107667.0000000000"
    SALES_PRODUCT_WID (SALES_PRODUCT_WID:Double:): "5093039.000000000"
    INVENTORY_PRODUCT_WID (INVENTORY_PRODUCT_WID:Double:): "4376743.000000000"
    SUPPLIER_PRODUCT_WID (SUPPLIER_PRODUCT_WID:Double:): "0.00000000000000"
    COMPANY_LOC_WID (COMPANY_LOC_WID:Double:): "0.00000000000000"
    PLANT_LOC_WID (PLANT_LOC_WID:Double:): "2147.000000000000"
    SALES_OFC_LOC_WID (SALES_OFC_LOC_WID:Double:): "0.00000000000000"
    LEDGER_WID (LEDGER_WID:Double:): "2030.000000000000"
    COMPANY_ORG_WID (COMPANY_ORG_WID:Double:): "0.00000000000000"
    BUSN_AREA_ORG_WID (BUSN_AREA_ORG_WID:Double:): "0.00000000000000"
    CTRL_AREA_ORG_WID (CTRL_AREA_ORG_WID:Double:): "0.00000000000000"
    FIN_AREA_ORG_WID (FIN_AREA_ORG_WID:Double:): "0.00000000000000"
    SALES_ORG_WID (SALES_ORG_WID:Double:): "0.00000000000000"
    PURCH_ORG_WID (PURCH_ORG_WID:Double:): "0.00000000000000"
    ISSUE_ORG_WID (ISSUE_ORG_WID:Double:): "0.00000000000000"
    DOC_TYPE_WID (DOC_TYPE_WID:Double:): "6111.000000000000"
    CLRNG_DOC_TYPE_WID (CLRNG_DOC_TYPE_WID:Double:): "0.00000000000000"
    POSTING_TYPE_WID (POSTING_TYPE_WID:Double:): "0.00000000000000"
    CLR_POST_TYPE_WID (CLR_POST_TYPE_WID:Double:): "0.00000000000000"
    COST_CENTER_WID (COST_CENTER_WID:Double:): "3317.000000000000"
    PROFIT_CENTER_WID (PROFIT_CENTER_WID:Double:): "2025.000000000000"
    BANK_WID (BANK_WID:Double:): "0.00000000000000"
    PAY_TERMS_WID (PAY_TERMS_WID:Double:): "0.00000000000000"
    TRANSACTION_DT_WID (TRANSACTION_DT_WID:Double:): "20090211.00000000"
    TRANSACTION_TM_WID (TRANSACTION_TM_WID:Double:): "0.00000000000000"
    CONVERSION_DT_WID (CONVERSION_DT_WID:Double:): "0.00000000000000"
    ORDERED_ON_DT_WID (ORDERED_ON_DT_WID:Double:): "0.00000000000000"
    INVOICED_ON_DT_WID (INVOICED_ON_DT_WID:Double:): "0.00000000000000"
    DELIVERED_ON_DT_WID (DELIVERED_ON_DT_WID:Double:): "0.00000000000000"
    CUSTOMER_REQUEST_DT_WID (CUSTOMER_REQUEST_DT_WID:Double:): "0.00000000000000"
    GOODS_ISSUE_DT_WID (GOODS_ISSUE_DT_WID:Double:): "0.00000000000000"
    STOCK_XFER_DT_WID (STOCK_XFER_DT_WID:Double:): "0.00000000000000"
    CLEARING_DOC_DT_WID (CLEARING_DOC_DT_WID:Double:): "0.00000000000000"
    BASELINE_DT_WID (BASELINE_DT_WID:Double:): "0.00000000000000"
    PLANNING_DT_WID (PLANNING_DT_WID:Double:): "0.00000000000000"
    ACCOUNT_DOC_ID (ACCOUNT_DOC_ID:UniChar.80:): "2899322~12389~Feb-09~230"
    COGS_DOC_AMT (COGS_DOC_AMT:Double:): "30.00000000000000"
    COGS_LOC_AMT (COGS_LOC_AMT:Double:): "30.00000000000000"
    XACT_QTY (XACT_QTY:Double:): "1.000000000000000"
    UOM_CODE (UOM_CODE:UniChar.50:): ""
    DB_CR_IND (DB_CR_IND:UniChar.30:): "DEBIT"
    ACCT_DOC_NUM (ACCT_DOC_NUM:UniChar.30:): "(NULL)"
    ACCT_DOC_ITEM (ACCT_DOC_ITEM:Double:): "(NULL)"
    ACCT_DOC_SUB_ITEM (ACCT_DOC_SUB_ITEM:Double:): "(NULL)"
    CLEARING_DOC_NUM (CLEARING_DOC_NUM:UniChar.30:): "(NULL)"
    CLEARING_DOC_ITEM (CLEARING_DOC_ITEM:Double:): "(NULL)"
    SALES_ORDER_NUM (SALES_ORDER_NUM:UniChar.30:): "(NULL)"
    SALES_ORDER_ITEM (SALES_ORDER_ITEM:Double:): "(NULL)"
    SALES_SCH_LINE (SALES_SCH_LINE:Double:): "(NULL)"
    INVOICE_NUM (INVOICE_NUM:UniChar.30:): "(NULL)"
    INVOICE_ITEM (INVOICE_ITEM:Double:): "(NULL)"
    DELIVERY_DOC_NUM (DELIVERY_DOC_NUM:UniChar.30:): "(NULL)"
    DELIVERY_DOC_ITEM (DELIVERY_DOC_ITEM:Double:): "(NULL)"
    GI_DOC_NUM (GI_DOC_NUM:UniChar.30:): "(NULL)"
    GI_DOC_ITEM (GI_DOC_ITEM:Double:): "(NULL)"
    STO_DOC_NUM (STO_DOC_NUM:UniChar.30:): "(NULL)"
    STO_DOC_ITEM (STO_DOC_ITEM:Double:): "(NULL)"
    DOC_HEADER_TEXT (DOC_HEADER_TEXT:UniChar.255:): "(NULL)"
    LINE_ITEM_TEXT (LINE_ITEM_TEXT:UniChar.255:): "(NULL)"
    ALLOCATION_NUM (ALLOCATION_NUM:UniChar.30:): "(NULL)"
    FED_BALANCE_ID (FED_BALANCE_ID:UniChar.320:): "12389~10004~BUDGET~~10004~~"
    BALANCE_ID (BALANCE_ID:UniChar.320:): "10004~12389~"
    DOC_STATUS_WID (DOC_STATUS_WID:Double:): "102006.0000000000"
    POSTED_ON_DT_WID (POSTED_ON_DT_WID:Double:): "20090211.00000000"
    POSTED_ON_TM_WID (POSTED_ON_TM_WID:Double:): "20090211.00000000"
    CLEARED_ON_DT_WID (CLEARED_ON_DT_WID:Double:): "0.00000000000000"
    GL_RECONCILED_ON_DT (GL_RECONCILED_ON_DT:Date:): "(NULL)"
    DOC_CURR_CODE (DOC_CURR_CODE:UniChar.30:): "USD"
    LOC_CURR_CODE (LOC_CURR_CODE:UniChar.30:): "USD"
    LOC_EXCHANGE_RATE (LOC_EXCHANGE_RATE:Double:): "1.000000000000000"
    GLOBAL1_EXCHANGE_RATE (GLOBAL1_EXCHANGE_RATE:Double:): "1.000000000000000"
    GLOBAL2_EXCHANGE_RATE (GLOBAL2_EXCHANGE_RATE:Double:): "33.96700000000000"
    GLOBAL3_EXCHANGE_RATE (GLOBAL3_EXCHANGE_RATE:Double:): "1.000000000000000"
    CREATED_BY_WID (CREATED_BY_WID:Double:): "11254.00000000000"
    CHANGED_BY_WID (CHANGED_BY_WID:Double:): "11254.00000000000"
    CREATED_ON_DT (CREATED_ON_DT:Date:): "02/11/2009 14:56:23"
    CHANGED_ON_DT (CHANGED_ON_DT:Date:): "(NULL)"
    AUX1_CHANGED_ON_DT (AUX1_CHANGED_ON_DT:Date:): "02/11/2009 14:56:23"
    AUX2_CHANGED_ON_DT (AUX2_CHANGED_ON_DT:Date:): "(NULL)"
    AUX3_CHANGED_ON_DT (AUX3_CHANGED_ON_DT:Date:): "(NULL)"
    AUX4_CHANGED_ON_DT (AUX4_CHANGED_ON_DT:Date:): "(NULL)"
    DELETE_FLG (DELETE_FLG:UniChar.1:): "N"
    W_INSERT_DT (W_INSERT_DT:Date:): "11/17/2009 18:39:40"
    W_UPDATE_DT (W_UPDATE_DT:Date:): "11/17/2009 18:39:40"
    DATASOURCE_NUM_ID (DATASOURCE_NUM_ID:Double:): "41.00000000000000"
    ETL_PROC_WID (ETL_PROC_WID:Double:): "16.00000000000000"
    INTEGRATION_ID (INTEGRATION_ID:UniChar.80:): "46214900~12389~2899322~Feb-09~230"
    TENANT_ID (TENANT_ID:UniChar.80:): "DEFAULT"
    X_CUSTOM (X_CUSTOM:UniChar.10:): "(NULL)"
    GL_RECONCILED_ON_PROC_WID (GL_RECONCILED_ON_PROC_WID:Double:): "(NULL)"
    )

    ETL will do a commit for every 10k records i believe. Might be when it is trying to insert the first 10k records it is having the duplicates. So check in the staging table whether that unique column combination is having any duplicates.

  • Unique constraint is not thrown when used MERGE INSERT (alone) via dblink.

    We found some interesting behaviour of unique constraint on Merge query when we use Merge When Not Matched Insert (no update query) via a dblink.
    In one Schema S1, on Table A1(c1,c2,c3) there is a unique constraint on column (c1,c2).
    Column c2 is nullable and has null for some records.
    Now i have a table A2 with same defintion as A1 in Schema S2.In S2 , i have a dblink of S1 as S1 itself.
    I have data in S2.A2. Here also i have some records with c2 as null and c1 matching with the data of S1.A1.
    Now from schema S2,
    I am using the following Merge Query,
    MERGE INTO S1.A1 target
    USING S2.A2 source
    ON (target.c1 = source.c1 and target.c2 = source.c2)
    WHEN NOT MATCHED
    INSERT (c1,c2,c3) values (source.c1, source.c2,source.c3)
    WHEN MATCHED
    UPDATE c3 = source.c3;
    Now when i execute this merge in schema S2,
    if i have some data in S1.A1 and S2.A2 having c1 as same and c2 as null, as oracle does not treat two nulls same, it goes for an insert, i have got unique constraint violated error.
    But if i execute MERGE INSERT alone, though that record is getting inserted , i am not getting unique constraint violated error.
    Oracle version we are using is 10g (10.2...).
    Is it a bug in oracle or what could have caused this behaviour.

    Dear,
    ERROR at line 1:
    ORA-00001: unique constraint (SYS_C00137508) violatedYou need to think about two things
    (a) read consistency : what was the situation of table_1 when the maching clause has been initially evaluated ; there were 0 rows matching which means the merge operation will be all insert
    (b) your matching clause has a problem : the join column must be unique in both tables otherwise the merge will be ambigous. You don't have a unique key on the source table
    (c) think that the merge operation will never insert id =1 and then update id = 1 within the same operation. This will never happen
    Hope this helps
    Mohamed Houri

  • UNIQUE constraint vs checking before INSERT

    I have a SQL server table RealEstate with columns - Id, Property, Property_Value. This table has about 5-10 million rows and can increase even more in the future. I want to insert a row only if a combination of Id, Property, Property_Value does not exist
    in this table.
    Example Table -
    1,Rooms,5
    1,Bath,2
    1,Address,New York
    2,Rooms,2
    2,Bath,1
    2,Address,Miami
    Inserting 2,Address,Miami should NOT be allowed. But, 2,Price,2billion is okay. I am curious to know which is the "best" way to do this and
    why. The why part is most important to me.
    Check if a row exists before you insert it.
    Set unique constraints on all 3 columns and let the database do the checking for you.
    Is there any scenario where one would be better than the other ?
    Thanks.

    Why? 
    Because the database engine does exactly what you want - it is designed to do this in a way that anticipates collisions with simultaneous inserts and allows only a single row for any given combination of values.  If you choose to manage this at the
    application level - which is the alternative you propose - then EVERY application that attempts to insert rows must be designed to both check immediately before insertion and immediately afterwards (since these inserts can occur simulateously and you must
    allow for communication delays between database and client).  And since we know that programmers are not infallible (many other adjectives come to mind as well), there exists a high probability that the duplicate checking logic will fail.  And do
    not forget that there are many ways of inserting data into the table - it is not just your front-end application that must use this logic - it is also every other application that is used to manage data (such as SSMS, SSIS, bcp, etc.) 

  • Unique constraint violation - Finding inserted row before commit

    Hi,
      I have a scenario something like that, where I need to insert a row to a table - contact, for different employees under different department. So I happen to insert same employee contact multiple times & do commit at the last if there is no contact in the table. How to find out if the same employee record is already inserted ?.
    The unique constraints is on emp id + depatment id in the contact table. So I face the issue when i do the commit, it finds the same emp id + dept id contact has been inserted multiple times.
    Please let me know how to handle it?
    Regards,
    Dhamo.

    Hi
    What is exactly what you want to achieve? Do you want to display a message to the user? Do you want to prevent it to post the contact if it already exists?
    Regards

  • Unique constraint violation error

    Hello All,
    I have a procedure called - FHM_DASHBOARD_PROC which inserts the data into a table called FHM_DASHBOARD_F fetching records from several tables. However, for a particular type of record, that data is not being inserted because of the Unique constraint violation
    the procedure is:
    create or replace
    PROCEDURE FHM_DASHBOARD_PROC AS
    DB_METRICS_CNT1Z number;
    --V_PODNAME varchar2(10);
    V_KI_CODE_DB_STATSZ varchar2(50);
    V_ERRORSTRING varchar2(100);
    --CURSOR PODNAME_CUR IS SELECT PODNAME,SHORTNAME FROM CRMODDEV.POD_DATA WHERE PODSTATUS_ID=1 AND PODTYPE_ID=1 ORDER BY PODNAME;
    -- DB STATS
    BEGIN
      -- OPEN PODNAME_CUR;
        --   LOOP
          --   FETCH PODNAME_CUR INTO V_PODNAME,V_POD_SHORTNAME ;
            -- EXIT WHEN PODNAME_CUR%NOTFOUND;
               BEGIN
                     SELECT COUNT(*) INTO DB_METRICS_CNT1Z FROM FHM_DB_METRICS_F A, FHM_DB_D B where A.DBNAME=B.DBNAME and PODNAME=V_PODNAME AND DB_DATE=TRUNC(SYSDATE-1);
                               DBMS_OUTPUT.PUT_LINE('DB_METRICS_CNT1Z :'|| DB_METRICS_CNT1Z);
                               IF DB_METRICS_CNT1Z >0 THEN
                        DBMS_OUTPUT.PUT_LINE('DB STATS');
                       INSERT INTO FHM_DASHBOARD_F(PODNAME,DASH_DATE,KI_CODE,KI_VALUE,KI_STATUS)
                          (SELECT PODNAME, DASH_DATE AS CU_DATE, KI.KI_CODE, NVL(PF.KI_VALUE,0),
                                                                  CASE
                                                                   WHEN PF.KI_VALUE = ki.warning_threshold then 2
                        when PF.KI_VALUE=0 then 0
                        ELSE 1
                        END  AS ALERT_STATUS
                        FROM
                        (SELECT PODNAME,DB_DATE AS DASH_DATE,decode(a.stats_last_status,'SUCCEEDED',1,'FAILED',2,'STOPPED',2,NULL,0) KI_VALUE from 
                        FHM_DB_METRICS_F a,fhm_db_d b where a.dbname=b.dbname and podname='XYZ' and db_date=TRUNC(SYSDATE-1) and dbtype='OLTP')PF,
                        FHM_KEY_INDICATOR_D KI where PF.PODNAME=KI.POD_NAME AND KI.TIER_CODE=3 AND KI.KI_NAME='DB_STATS'
                        AND (PF.PODNAME,TRUNC(PF.DASH_DATE),KI.KI_CODE) NOT IN (SELECT PODNAME,DASH_DATE,KI_CODE FROM FHM_DASHBOARD_F));
                                 COMMIT;
                             ELSE
                                    SELECT KI_CODE INTO V_KI_CODE_DB_STATSZ FROM FHM_KEY_INDICATOR_D WHERE POD_NAME=V_PODNAME AND KI_NAME='DB_STATS';
                                     DBMS_OUTPUT.PUT_LINE('V_KI_CODE_DB_STATSZ :'||V_KI_CODE_DB_STATSZ);
                                     INSERT INTO FHM_DASHBOARD_F(PODNAME,DASH_DATE,KI_CODE,KI_VALUE,KI_STATUS) VALUES(V_PODNAME,TRUNC(SYSDATE-1),V_KI_CODE_DB_STATSZ,0,0);
                                     COMMIT;
                             END IF;
         EXCEPTION
                            WHEN OTHERS THEN
                            V_ERRORSTRING :='INSERT INTO FHM_DASHBOARD_F_ERROR_LOG(POD_NAME,KI_NAME,ERRORNO,ERRORMESSAGE,DATETIME) VALUES
                   ('''||V_PODNAME||''',''DB_STATS'','''||SQLCODE||''','''||SQLERRM||''',SYSDATE)';                        
                   EXECUTE IMMEDIATE  V_ERRORSTRING;
                            COMMIT;
              END;
          --END LOOP;
      --CLOSE PODNAME_CUR;
    END;
    END FHM_DASHBOARD_PROC;and the table where the data is inserting is
    CREATE TABLE "CRMODDEV"."FHM_DASHBOARD_F"
        "PODNAME" VARCHAR2(25 BYTE) NOT NULL ENABLE,
        "DASH_DATE" DATE,
        "KI_CODE"   NUMBER NOT NULL ENABLE,
        "KI_VALUE"  NUMBER,
        "KI_STATUS" NUMBER,
        CONSTRAINT "FHM_DASHBOARD_F_DATE_PK" PRIMARY KEY ("DASH_DATE", "PODNAME", "KI_CODE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CRMODDEV_IDX" ENABLE,
        CONSTRAINT "FHM_DASHBOARD_F_KI_CODE_FK" FOREIGN KEY ("KI_CODE") REFERENCES "CRMODDEV"."FHM_KEY_INDICATOR_D" ("KI_CODE") ENABLE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS NOLOGGING STORAGE
        INITIAL 3145728 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "CRMODDEV_TBL" ENABLE ROW MOVEMENT ;the Primary key constraint is FHM_DASHBOARD_F_DATE_PK and is on 3 columns of the table DASH_DATE, PODNAME, KI_CODE
    And this is the query used in the Procedure for inserting the data into the table
    (SELECT  PODNAME, DASH_DATE AS CU_DATE, KI.KI_CODE, NVL(PF.KI_VALUE,0),
                                   CASE
                                   WHEN PF.KI_VALUE = ki.warning_threshold then 2
    when PF.KI_VALUE=0 then 0
    ELSE 1
    END  AS ALERT_STATUS
    From
    (Select  Podname,Db_Date As Dash_Date,Decode(A.Stats_Last_Status,'SUCCEEDED',1,'FAILED',2,'STOPPED',2,Null,0) Ki_Value From  -- Added Distinct
    FHM_DB_METRICS_F a,fhm_db_d b where a.dbname=b.dbname and podname in ('XYZ') and db_date = TRUNC(SYSDATE-2) and dbtype='OLTP')PF,
    Fhm_Key_Indicator_D Ki Where Pf.Podname=Ki.Pod_Name And Ki.Tier_Code=3 And Ki.Ki_Name='DB_STATS'
    And (Pf.Podname,Trunc(Pf.Dash_Date),Ki.Ki_Code) Not In (Select Podname,Dash_Date,Ki_Code From Fhm_Dashboard_F));It gives *2 record* as result
    XYZ 20-JAN-12     2521     1     1
    XYZ 20-JAN-12     2521     1     1
    So it gives Unique constraint violation error while inserting. Then, I changed in the above inserting code by adding a distinct clause. After that the query gives only ONE record as result. However, that record also is not being inserted into the table and giving the same error.
    Now the question is How shall I insert this record into the table successfully ?
    Though the message is too long, However, I have given you the full structure of the object/procedure and error.
    Thank You in Advance.

    when you have 5 columns in the result set adding DISTINCT is n ot the solution as you may get the same error again.
    Check the target table whether the data exists before inserting ..if not check the table structure for unique constraint created on other columns.
    select *from <table_name>
    where
    DASH_DATE=date '2012-01-20'
    and PODNAME='XYZ'
    and  KI_CODE=2521;

  • Unique constraint deployable=false

    I am new to OWB. We are using client version 10.1.0.2.0.
    We have a mapping where the target table (a cube) is set to update/insert, match by a unique constraint which comprises two values. A non-unique index on the cube comprises the same two values. The constraint is set to deployable=false, so of course the constraint is not on the table in the database when the cube is deployed. The corresponding non-unique index is set to deployable=true, so it is on the deployed cube in the database.
    My question: Why set a constraint (especially a unique constraint) to not deploy? Does OWB still check the constraint to make sure it's not a duplicate before inserting a new record, and if so, what is it checking if the constraint does not exist on the table and the associated index is not unique?
    I searched the forum to see if this question had been answered, but was not able to find what I was looking for. I also tried the OWB user docs and help, but didn't find the answer. They tell me what deployable means, but not why to set it a certain way. If it is in docs anywhere, please direct me to the answer.
    TIA

    Hi
    Where do you see in Oracle Warehouse Builder: "constraint is set to deployable=false"?
    Ott Karesz
    http://www.trendo-kft.hu

  • Insert called before delete in a collection with unique constraint

    Hi all,
    I have a simple @OneToMany private mapping:
    private Collection<Item> items;
    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
    public Collection<Item> getItems() {
    return items;
    public void setItems(Collection<Item> items) {
    this.items = items;
    public void customize(ClassDescriptor classDescriptor) throws Exception {
    OneToManyMapping mapping = (OneToManyMapping)
    classDescriptor.getMappingForAttributeName("items");
    mapping.privateOwnedRelationship();
    I have a unique constraint on my Items table that a certain value cannot be duplicated.
    My problem appears when I remove a previously saved item from the collection and add a new item containing the same data, at the same time.
    After I save the parent and do a flush, I receive SQLIntegrityConstraintViolationException because TopLink performs first an insert query instead of deleting the existing item.
    I tested the application and everything went fine with: remove item / save parent / insert item / save parent
    I checked on the Internet and the documentation but didn't find anything similar to my problem. I tried debugging TopLink's internal calls but I'm missing some general ideas about all the inner workings and don't know what to look for. I use TopLink version: Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))
    Does anyone have a hint of what to look for?
    Edited by: wise_guybg on Sep 25, 2009 4:01 PM
    Edited by: wise_guybg on Oct 5, 2009 11:22 AM

    Thank you for the suggestions James
    As I mentioned briefly I have done some debugging but couldn't understand how collections are updated. What I did find out is that setShouldPerformDeletesFirst() doesn't come into play in this case because this is not a consecutive change on entities.
    What I have in my case is a collection inside an entity that the user has tampered with and now TopLink has to do a merge. I cannot call flush() in the middle since the user has not approved that the changes made to the entity should be saved.
    I see that for TopLink it's not easy to figure out the order in which changes were made to a collection. Here is pseudo-code of when the constraint is touched:
    entity.items.remove(a)
    entity.items.add(b)
    merge(entity)
    And here is code that executes without a problem:
    entity.items.remove(a)
    merge(entity)
    entity.items.add(b)
    merge(entity)
    So once again, I think that collection changes are managed differently but I don't find a way to tell TopLink how to handle them. Any ideas?

  • Unique constraint error on delete/insert

    Hi,
    I am using Jdeveloper 11.1.1.3.0. I have a ADF table where we can copy lines and delete lines. I get unique constraint error when I save. Looks like the insert operation in happening before the delete operation. Is there a way to set the execution order so that the logical behaviour is delete/update/insert.
    Thanks
    SV

    Hi,
    The unquie contraint is not from the primary key. There are three columns in the table (batch_id, line_number, line_type) which must be unique. In the UI, the user can delete lines, update lines and add lines and finally click the save button that does the commit. On delete the line_number gets re-numbered. So when committing, the unique error occurs because the line number already exists. Looks like insert is happening before update/delete. I cannot do commit after each delete/update/insert. I have to do it only if the user clicks the save button in the end. Is there a way to control the order of execution?
    SR

  • Reattempt of insert after a ORA-0001 unique constraint violation

    Hi,
    I'm inserting into a table. The primary key on this table is made up of the user id and a one-up transaction number. Unfortunately, I cannot change the design of this table.
    Because I have to query the table to get the next transaction number before I insert into the table, I sometimes get a ORA-0001 (unique constraint violation) error because some other session grabbed the next transaction number and committed before I did.
    To deal with this I retry the insert, that is, read the table again for the next tran number and insert. I allow for this up to 3 times. If after the third attempt I fail again, I rollback.
    I'm seeing 3 records in the table.
    So here are my questions: Do I need to rollback when I get the ORA-0001 error? I thought I wouldn't have to. If I do, why? The insert failed, how could the commit statement commit 3 records?
    Thanks!

    No, the userid and transaction numbers are not the same (combined) for each of the 3 rows.
    Here is the logic to retry again when I get a ORA-0001:
    PROCEDURE insert_record(
    table1_rec_in IN table1%ROWTYPE,
    tran_number OUT table1.trans_number%TYPE,
    attempt_number IN PLS_INTEGER)
    IS
    next_tran_number table1.trans_number%TYPE;
    BEGIN
    SELECT NVL(MAX(trans_number), 0) + 1
    INTO next_tran_number
    FROM table1
    WHERE userid = table1_rec_in.table1_userid;
    INSERT INTO table1
    (userid,
    trans_number,
    amount,
    transdate)
    VALUES
    (table1_rec_in.userid,
    next_tran_number,
    table1_rec_in.amount,
    SYSDATE);
    tran_number := next_tran_number;
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX THEN
    IF attempt_number < 3
    THEN
    DECLARE
    next_attempt_number PLS_INTEGER;
    BEGIN
    next_attempt_number := attempt_number + 1;
    insert_record(
    table1_rec_in,
    tran_number,
    next_attempt_number);
    END;
    ELSE
    RAISE unable_to_insert_rec;
    END IF;
    WHEN OTHERS THEN
    RAISE unable_to_insert_rec;
    END;
    I'm using recursion to try the insert again. Is this the source of my problems? I don't see it and can't reproduce it.

  • ORA-00001:Unique Constraint while inserting 2 similar records from source

    Hi,
    in TEST1 there are records:
    10 20 ABC
    10 20 DEF
    I amt trying to insert into TEST which has CODE as Primary Key.
    declare
    type cur is ref cursor;
    cur_t cur;
    type v_t is table of TEST%rowtype;
    tab v_t;
    v_act_cnt_str VARCHAR2(4000);
    v_act_cnt NUMBER:=0;
    BEGIN
    v_act_cnt_str:=' SELECT COUNT(*) '||' FROM TEST '||' WHERE '||'('||CODE||')'||' IN '||'('||'SELECT '||CODE||' FROM TEST1'||')';
    DBMS_OUTPUT.PUT_LINE('The Actual Count String is'||v_act_cnt_str);
    EXECUTE IMMEDIATE v_act_cnt_str INTO v_act_cnt;
    open cur_t for select * from TEST1 ORDER BY ROWNUM;
    loop
    fetch cur_t bulk collect into tab limit 10000;
    if v_act_cnt=0 THEN
    forall i in 1..tab.count
    insert into TEST values tab(i);
    commit;
    ELSE
    v_merge_act_str :=
    'MERGE INTO TEST '||
    ' DEST' || ' USING TEST1 '||
    ' SRC' || ' ON (' || DEST.CODE=SRC.CODE || ')' ||
    ' WHEN MATCHED THEN ';
    first_str := 'UPDATE ' || ' SET ' ||
    'DEST.NAME=SRC.NAME,DEST.DEPT_NAME=SRC.DEPT_NAME;
    execute immediate v_merge_act_str || first_str;
    v_merge_act_str := '';
    first_str := '';
    commit;
    END IF;
    end loop;
    END;
    ITS GIVING ERROR as:
    ORA-00001: unique constraint (PK_TEST1) violated
    Any help will be needful for me
    Edited by: user598986 on Sep 22, 2009 4:20 AM
    Edited by: user598986 on Sep 22, 2009 4:22 AM

    Your code makes absolutely no sense whatsover. The whole point of MERGE is that it allows us to conditionally apply records from a source table as inserts or updates to a target table. So why have you coded two separate statements? And why are you using such horrible dynamic SQL?
    Sorry to unload on you, but you seem to have your code unnecessarily complicated, and that it turn makes it unnecessarily harder to debug. As an added "bonus" this approach will also perform considerably slower than a single MERGE statement. SQL is all about set operations. Don't do anything procedurally which can be done in a set.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • PK with TIMESTAMP causes insert unique constraint error at DST switch

    Hi,
    I have a test that inserts rows in a table that has a TIMESTAMP in its PK.
    When inserting rows that cross over the November DST change, it tries to insert these dates:
    --- Sun Nov 02 02:00:00 EST 2008
    --- Sun Nov 02 01:00:00 EST 2008
    --- Sun Nov 02 01:00:00 EDT 2008
    This is the output of 3 different UTC dates. We can see that there are 2 x 1am, but they differ in their DST. They are really 3 different UTC dates.
    But I get this error:
    --- Expected error: ORA-00001: unique constraint (DDLTEST1.SYS_C00142622) violated
    But I can get around that error and can insert these same dates if I set my JVM to UTC. The inserts work so I suspect this to be a JDBC issue.
    I am using the Oracle Thin driver in a spring app:
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@localhost:db" />
    I can post the sample code but wonder if there is an obvious answer to this.
    Note that MySql had the same problem. I fixed it by specifying the UTC timezone in the connection string, like this:
    jdbc:mysql://[host]/[db]?useLegacyDatetimeCode=false&useTimezone=true&sessionVariables=time_zone='UTC'
    Any idea how to get around that problem without setting JVM to UTC ?
    Claude
    Edited by: user2678899 on 10 juin 2009 10:09
    I removed #2 work around which was wrong
    Edited by: user2678899 on 10 juin 2009 10:23

    Timur Akhmadeev wrote:
    Hi,
    I suspect this to be a JDBC issue.Nope, this is your schema design gap. It breaks the main principle of PK: to uniquely identify a row in a table always. Your PK doesn't satisfy it, since it depends on client's settings.Why is setting the JVM to UTC working ? This is the part that confuses me.
    I create the 3 dates in Eastern time, then change the JVM default to UTC: the 3 inserts work.
    I create the 3 dates in Eastern time, then leave the JVM to Eastern time , the 3rd insert gets the unique constraint error.
    To me, the PK principle is not broken: these are 3 different UTC dates.

  • Insert result of query into a table with unique constraint

    Hi,
    I have a query result that I would like to store in a table. The target table has a unique constraint. In MySQL you can do
    insert IGNORE into myResultTable <...select statement...>
    The IGNORE clause means if inserting a row would violate a unique or primary key constraint, do not insert the row, but continue inserting the rest of the query. Leaving the IGNORE clause out would cause the insert to fail and an error to return.
    I would like to do this in oracle... that is insert the results of a query that are not already in the target table. What is the best way to do this? One way is use a procedural language and loop through the first query, checking to see if each row is a duplicate before inserting it. I would think this would be slow if there are lots of records. Other options...
    insert into myTargetTable
    select value from mySourceTable where ... and not exists (select 'x' from myTargetTable where value = mySourceTable.value)
    insert into myTargetTable
    select mySourceTable.value
    from myTargetTable RIGHT JOIN mySourceTable
    ON myTargetTable.value = mySourceTable.value
    where ...
    and myTargetTable.value IS NULL
    any other suggestions?
    Thanks,
    Simon

    Try doing a MINUS instead of not exists., ie Source MINUS Target.
    Disabling the constraint will not help you since this will allow the duplicate rows to be inserted into the table. I don't think you want this.
    --kalpana                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Unique constraint ERROR How to update the task order customly?

    I am using DAC to load data from Siebel database into Oracle Business Analytic Data Warehouse for BI Apps. Now we encounter a question. I need some help.
    When I run current execute plan, the Custom_shyy_SIL_ActivityFact is failured.Beause the *'unique constraint (SHYY_OLAP_DEV.W_ACTIVITY_F_U1) violated'* ORA_00001 ERROR. I analyse this question.At last, I think this question is caused with some below reason.
    My custom execute plan include some Update Dimension from Dimension tasks. They are SIL_EmployeeDimension_SCDUpdate and SIL_ProductDimension_SCDUpdate and so no. that tasks that marked Update Dimension from Dimension run before the Custom_shyy_SIL_ActivityFact. And, in the w_product_d one integration_id corresponding with two records, but the curent_flag ='Y' recored is only. Now ,I Think the SDCU Task is run before the Load fact tack. I discoved it does't work. please help me !

    Hey
    When Doing a full Load through DAC it drops all the unique indexes and then inserts the data and recreates the indexes again.The Index Creation fails if there are duplicate rows (Rows with same integration_id).
    So start Checking the Data right from the Source Level.
    First check the Source (do this using the integration_id thats repeating,Go through the informatica Mappings(ETL Mappings).
    If its Fine there Come to the Staging Level and Check for Duplicate Columns.
    Then Check in the final Table for Duplicate records.
    My Guess is that you are having duplicate rows at the Source level.
    If your are using informatica try using distinct for the SQL in the Source Qualifier(think that should block any duplicate records).
    Update here If you are able to solve this.
    Thanks
    Hemanth

  • TopLink inserts when it should update, unique constraint exception

    The title says most of it. I am creating a series of objects and then updating them in rapid succession. It would be great to handle all the values during the insert, but it's not possible for this process. The majority of the time, the cached object is updated correctly and no problem occurs, but every once in a while TopLink tries to re-insert the previously inserted object, instead of updating it. Obviously this throws a unique constraint exception for the PK, and boots me out of the process.
    I can refreshObject and then it works fine. I'm looking for the underlying cause though. I want to be able to use the cache!
    Thanks!!
    Aaron
    Oracle JDBC driver Version: 10.2.0.3.0
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    TopLink Release-Designation: 10g Release 3

    Hello,
    How are you obtaining these objects to update them? The likely cause is that you are running out of memory and the objects in the shared identity map are getting garbage collected due to weak references. This means that when they get registered, TopLink can't find them in the cache so assumes they are new (the default existence check is check cache).
    If this is the case, there are a few options.
    1) Increase the size of the cache for the class in question to something more appropriate for your application, or use a fullIdentyMap so nothing ever gets pushed out. Of course, a FullIdentityMap should not be used lightly as it prevents its objects from beign gc'd and has consequences to related objects as described in:
    Caching Causing Memory Leak Effect
    Both these options will require more memory resources though, so if garbage collection is running and clearing out the references because you are already low on memory, this might make GC need to run more frequently
    2) Increase the JVM memory. This assumes completely that GC is clearing out the unused weak references from your cache because it is low on memory - GC can still occur so it doesn't guarantee the problem will be any better
    3) Read in the object through the UnitofWork before making changes (instead of using RegisterObject on existing objects), use the registerExistingObject for known existing objects or use the uow mergeClone method. Merge should cause the object to be read from the database if it is not in the cache, but it depends on the existence options used
    Best Regards,
    Chris

Maybe you are looking for