Hey all, I have a setup where I have an optional to-one relationship, but when I try to clear the relationship and commitChanges, I get a low-level Cayenne error along with some in appropriate sql generated.
where it's doing an UPDATE to order_detail_costs should be a no-op, because the object was removed from it's parent (order_detail_sales) with setOrderDetailCost(null) along with a objectContext.deleteObject(orderDetailCost). This is probably a problem for Nikita to look at, but I figured someone else may have run into this as well. It's unusual for me to have optional to-one relationships, but it does happen. Here is a sample project (Debug As -> Java Application) to try (link to my Synology): https://varscsak.synology.me:5001/d/s/mI7SBS6fApoUMNT1K5lfpaCXHKEkHkgd/jIy5Ug64Hjp2ieZzOceknc39sjBasJLE-T74gPgqKEgk ...snip... Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - INSERT INTO "order_header"( "attribute_1", "attribute_2", "order_number") VALUES( ?, ?, ?) Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - [bind: 1->attribute_1:'TEST1', 2->attribute_2:1, 3->order_number:1] Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - === updated 1 row. Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - INSERT INTO "order_detail_sales"( "detail_attr_1", "detail_attr_2", "order_line_number", "order_number") VALUES( ?, ?, ?, ?) Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - [bind: 1->detail_attr_1:'TEST1', 2->detail_attr_2:1, 3->order_line_number:1, 4->order_number:1] Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - === updated 1 row. Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - UPDATE "order_detail_costs" SET "order_number" = ?, "order_line_number" = ? WHERE ( "order_line_number" = ? ) AND ( "order_number" = ? ) Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - *** error. java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) at org.apache.cayenne.query.BatchQueryRow.getValue(BatchQueryRow.java:80) at org.apache.cayenne.query.UpdateBatchQuery$1.getValue( UpdateBatchQuery.java:124) at org.apache.cayenne.access.translator.batch.UpdateBatchTranslator.updateBindings( UpdateBatchTranslator.java:80) at org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries( BatchAction.java:191) at org.apache.cayenne.access.jdbc.BatchAction.performAction( BatchAction.java:93) at org.apache.cayenne.access.DataNodeQueryAction.runQuery( DataNodeQueryAction.java:97) at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273) at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.lambda$executeQueries$6( DefaultDataDomainFlushAction.java:177) at java.util.HashMap.forEach(HashMap.java:1290) at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.executeQueries( DefaultDataDomainFlushAction.java:176) at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.flush( DefaultDataDomainFlushAction.java:89) at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:637) at org.apache.cayenne.access.DataDomain.onSyncNoFilters(DataDomain.java:609) at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync( DataDomain.java:835) at org.apache.cayenne.tx.TransactionFilter.lambda$onSync$0( TransactionFilter.java:61) at org.apache.cayenne.tx.DefaultTransactionManager$BaseTransactionHandler.performInTransaction( DefaultTransactionManager.java:180) at org.apache.cayenne.tx.DefaultTransactionManager$BaseTransactionHandler.performInNewTransaction( DefaultTransactionManager.java:152) at org.apache.cayenne.tx.DefaultTransactionManager$NestedTransactionHandler.handle( DefaultTransactionManager.java:95) at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction( DefaultTransactionManager.java:62) at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction( DefaultTransactionManager.java:40) at org.apache.cayenne.tx.TransactionFilter.onSync(TransactionFilter.java:61) at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync( DataDomain.java:834) at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:596) at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:737) at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:686) at com.smarthealth.cayennetest.App.main(App.java:38) Nov 16 15:27:55 INFO org.apache.cayenne.log.JdbcEventLogger - *** transaction rolledback. org.apache.cayenne.CayenneRuntimeException: [v.4.2.M4-SNAPSHOT Nov 16 2021 22:12:02] Commit Exception at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:769) at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:686) at com.smarthealth.cayennetest.App.main(App.java:38) Caused by: java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) at org.apache.cayenne.query.BatchQueryRow.getValue(BatchQueryRow.java:80) at org.apache.cayenne.query.UpdateBatchQuery$1.getValue( UpdateBatchQuery.java:124) at org.apache.cayenne.access.translator.batch.UpdateBatchTranslator.updateBindings( UpdateBatchTranslator.java:80) at org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries( BatchAction.java:191) at org.apache.cayenne.access.jdbc.BatchAction.performAction( BatchAction.java:93) at org.apache.cayenne.access.DataNodeQueryAction.runQuery( DataNodeQueryAction.java:97) at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273) at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.lambda$executeQueries$6( DefaultDataDomainFlushAction.java:177) at java.util.HashMap.forEach(HashMap.java:1290) at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.executeQueries( DefaultDataDomainFlushAction.java:176) at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.flush( DefaultDataDomainFlushAction.java:89) at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:637) at org.apache.cayenne.access.DataDomain.onSyncNoFilters(DataDomain.java:609) at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync( DataDomain.java:835) at org.apache.cayenne.tx.TransactionFilter.lambda$onSync$0( TransactionFilter.java:61) at org.apache.cayenne.tx.DefaultTransactionManager$BaseTransactionHandler.performInTransaction( DefaultTransactionManager.java:180) at org.apache.cayenne.tx.DefaultTransactionManager$BaseTransactionHandler.performInNewTransaction( DefaultTransactionManager.java:152) at org.apache.cayenne.tx.DefaultTransactionManager$NestedTransactionHandler.handle( DefaultTransactionManager.java:95) at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction( DefaultTransactionManager.java:62) at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction( DefaultTransactionManager.java:40) at org.apache.cayenne.tx.TransactionFilter.onSync(TransactionFilter.java:61) at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync( DataDomain.java:834) at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:596) at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:737) ... 2 more