0

I have the following code:

    try (DB db = new DB()) {
        db.open(cpds);
        // Using the metadata to walk down the tree and identify all
        // children nodes to the leaf tables.
        // First the metadata for the pk of the target table
        List<Integer> recordIdList = new ArrayList<Integer>();
        recordIdList.add(recordId);

        batchInsertDeletePks(recordIdList, db);

        List<Integer> pkValues = new ArrayList<Integer>();
        pkValues.add(recordId);

        prepareChildDeletes(tablemeta_id, pkValues, recordId, db);

        ColumnData.delete("RECORD_ID IN (SELECT ID FROM TEMPDELETE)");
        noDeleted = RecordData.delete("ID IN (SELECT ID FROM TEMPDELETE)");
        TempDelete.deleteAll();

    } catch (Exception ex) {
        logger.debug(ex.getMessage());
    }

The TEMPDELETE has all of the primary keys I need to delete from COLUMNDATA. The ColumnData.delete is not working, the RecordData.delete is not working and the TempDelete.deleteAll is not working. They give no exceptions. The database is h2-1.4.196

If I debug trace into them and cut and paste the SQL that is created and run that SQL in a sql interpreter all the queries work just fine.

I cannot see what it is about my approach that is different to the examples? Any ideas?

oldDave
  • 395
  • 6
  • 25
  • you are omitting a lot of information, such as structure of your tables and code inside `recordIdList` and `prepareChildDeletes`. – ipolevoy Apr 09 '18 at 16:14
  • All you need to know is that there are 3 tables 1 contains ids, an Integer and the other 2 I want to delete from where a column value matches that in the table containing the ids (TEMPDELETE). TEMPDELETE has a single column called ID. Lets say that COLUMNDATA has a single column called RECORD_ID and RECORDDATA has a single column called ID. This can be inferred from the code above. – oldDave Apr 09 '18 at 22:04
  • 1
    if your delete statements do not delete anything this means they are not selecting records for deleting. The framework certainly knows how to delete :). You need to find bugs in your code. Every delete() method returns something, so you might want to start checking return values to see what is wrong – ipolevoy Apr 09 '18 at 22:39
  • Ah, the answer is right there. I have to do a Select first using the in clause and sub query. Something I was trying avoid. I'll try the Base.exec and native SQL to avoid this extra query – oldDave Apr 10 '18 at 09:29

0 Answers0