Created
December 2, 2016 15:22
-
-
Save Cepr0/9d2bbfb5f18fe18c37f1e2841db5655e to your computer and use it in GitHub Desktop.
Soft delete sample implementatioon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From here htps://github.com/olivergierke/repositories-deepdive/issues/1 | |
public interface SofDeleteRepo extends JpaRepository<Entity, Long> { | |
@Override | |
@Query("select e from #{#entityName} e where e.deleteFlag=false") | |
public List findAll(); | |
//Check entity in cycle bin. | |
@Query("select e from #{#entityName} e where e.deleteFlag=true") | |
public List recycleBin(); | |
//Some logicdelete method, or override the original delete method | |
@Query("update #{#entityName} e set e.deleteFlag=true where e.id=?1") | |
@Modifying | |
public void softDelete(String id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment