question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"onDelete = ForeignKeyAction.CASCADE" with no effects

See original GitHub issue

I try to use the “onDelete” with ForeignKeyAction.CASCADE but without success. I have the following annotation in a class that we will call MyClass:

    @Column(columnType = Column.FOREIGN_KEY, references = {@ForeignKeyReference(columnName = FIELD_MEDIA, columnType = Long.class, foreignColumnName = "id")}, onDelete = ForeignKeyAction.CASCADE, saveForeignKeyModel = false, uniqueGroups = 1)
    protected Media media;

But when i do this

        new Delete().from(MyClass.class).query();

The Media is not deleted. Any idea why?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
agrosnercommented, Apr 27, 2015

@YSDC do you have foreign key constraints turned on? @Database(foreignKeysSupported = true) ?

0reactions
fakencommented, Jul 4, 2017

I was wondering what’s currently the preferred way of making a OneToOne-Relation work. I’m struggling with getting it to work when I’m following the current Document of DBFlow 4.0.4.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Active Android onDelete and onDelete - Stack Overflow
NO ACTION: Configuring "NO ACTION" means just that: when a parent key is modified or deleted from the database, no special action is...
Read more >
Using the ON DELETE CASCADE Option - IBM
Use the ON DELETE CASCADE option to specify whether you want rows deleted in a child table when corresponding rows are deleted in...
Read more >
13.1.20.5 FOREIGN KEY Constraints - MySQL :: Developer Zone
A foreign key constraint on a stored generated column cannot use CASCADE , SET NULL , or SET DEFAULT as ON UPDATE referential...
Read more >
ForeignKey - Android Developers
A "CASCADE" action propagates the delete or update operation on the parent key to each dependent child key. For onDelete() action, this means...
Read more >
Foreign Key Constraint | CockroachDB Docs
ON DELETE CASCADE / ON UPDATE CASCADE, When a referenced foreign key is ... does not have a NOT NULL constraint, this will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found