soft-delete

Check if object is referenced to prevent soft-deleting without modifying database

末鹿安然 提交于 2021-02-08 02:15:20
问题 As you can see I am using soft/logical deletion on my system: My entities: @Where(clause = "deleted='false'") public class Person { //... } My services: @Override public ServiceResponse DeletePerson (Person entity) { ServiceResponse sr = new ServiceResponse<>(); try { sr = ValidateDeletePerson(entity); //Business logic treatment if (sr.hasError()) return sr; Person dbEntity = GetPerson(entity.getPersonID()); dbEntity.setDeleted(true); _repository.save(dbEntity); } catch (Exception ex) { sr

Check if object is referenced to prevent soft-deleting without modifying database

ぐ巨炮叔叔 提交于 2021-02-08 02:12:17
问题 As you can see I am using soft/logical deletion on my system: My entities: @Where(clause = "deleted='false'") public class Person { //... } My services: @Override public ServiceResponse DeletePerson (Person entity) { ServiceResponse sr = new ServiceResponse<>(); try { sr = ValidateDeletePerson(entity); //Business logic treatment if (sr.hasError()) return sr; Person dbEntity = GetPerson(entity.getPersonID()); dbEntity.setDeleted(true); _repository.save(dbEntity); } catch (Exception ex) { sr

Hibernate restore soft-deleted entity

最后都变了- 提交于 2020-12-07 05:05:30
问题 I have an entity @Entity @Table(name = "[Usermaster]") @SQLDelete(sql = "UPDATE Usermaster SET isDeleted = 1") @Where(clause = "isDeleted = 0") public class User { //... } Now when I delete some Entity it actually will set deleteFlag = 1 How can I restore the entity? thanks 来源: https://stackoverflow.com/questions/24656518/hibernate-restore-soft-deleted-entity

Hibernate restore soft-deleted entity

妖精的绣舞 提交于 2020-12-07 05:03:13
问题 I have an entity @Entity @Table(name = "[Usermaster]") @SQLDelete(sql = "UPDATE Usermaster SET isDeleted = 1") @Where(clause = "isDeleted = 0") public class User { //... } Now when I delete some Entity it actually will set deleteFlag = 1 How can I restore the entity? thanks 来源: https://stackoverflow.com/questions/24656518/hibernate-restore-soft-deleted-entity

Laravel still expects to find deleted_at column after I remove softDelete

荒凉一梦 提交于 2020-07-30 06:07:26
问题 I just removed softDelete from a table with this migration: Schema::table("items", function ($table) { $table->dropSoftDeletes(); }); But now every query results in: Column not found: 1054 Unknown column 'items.deleted_at' in 'where clause' Nowhere does the code explicitly refer to this column. Has it been cached somewhere, and if so, how to clear it? 回答1: You also need to remove the trait from the model: use SoftDeletes; From the docs: To enable soft deletes for a model, use the Illuminate

Laravel 5.2 soft delete does not work

筅森魡賤 提交于 2020-02-06 04:15:43
问题 I am have simple app with a table post and model: <?php namespace App; use Illuminate\Database\Eloquent\Model; use SoftDeletes; class Post extends Model { protected $table = 'post'; protected $dates = ['deleted_at']; protected $softDelete = true; } I am trying to make example of soft delete and i am using route just for example route.php: <?php use App\Post; use Illuminate\Database\Eloquent\SoftDeletes; Route::get('/delete', function(){ $post = new Post(); Post::find(12)->delete(); }); I have

Django, cascading move to a separate table instead of cascading delete

随声附和 提交于 2020-02-01 07:30:32
问题 I'd like to keep data when we delete instead of soft-delete (which uses is_deleted field), I'd like to move the data to another table (for deleted rows) https://stackoverflow.com/a/26125927/433570 I don't know what is the name of the strategy either. called archiving? two-table delete? To make this work, I need to be able to do for a given object(which will be deleted), find all other objects that has foreign key or one-to-one key to the object. (this can be done via https://stackoverflow.com

Django, cascading move to a separate table instead of cascading delete

守給你的承諾、 提交于 2020-02-01 07:29:23
问题 I'd like to keep data when we delete instead of soft-delete (which uses is_deleted field), I'd like to move the data to another table (for deleted rows) https://stackoverflow.com/a/26125927/433570 I don't know what is the name of the strategy either. called archiving? two-table delete? To make this work, I need to be able to do for a given object(which will be deleted), find all other objects that has foreign key or one-to-one key to the object. (this can be done via https://stackoverflow.com