Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-93

Joins in Criteria used to delete data can delete datasets also in joined table

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 3.3-RC3
    • Runtime
    • None

    Description

      Code to reproduce the error:
      criteria.add(BookPeer.AUTHOR_ID, authorId);
      criteria.addJoin(AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID);
      // the following is not needed from a SQL point of view but to generate the unexpected behaviour
      criteria.add(AuthorPeer.AUTHOR_ID, authorId);
      BookPeer.doDelete(criteria);

      Additionally to deleting the chosen books, this will also delete the corresponding authors. What happens is that the criteria gets passed to BasePeer, which tries to figure the table to delete from from the criteria alone. But as it contains two tables in the where clause, it does not know which one is the right table, and deletes the data from both tables.

      Attachments

        Activity

          People

            tfischer Thomas Fox
            tfischer Thomas Fox
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: