jpa-soft-delete-spring-boot-starter

Soft deletes for Spring Data Jpa

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

org.yuequan
ArtifactId

ArtifactId

jpa-soft-delete-spring-boot-starter
Last Version

Last Version

1.0.0.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

jpa-soft-delete-spring-boot-starter
Soft deletes for Spring Data Jpa
Project URL

Project URL

https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/jpa-soft-delete-spring-boot-starter
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/yuequan1997/jpa-soft-delete-spring-boot-starter

Download jpa-soft-delete-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/org.yuequan/jpa-soft-delete-spring-boot-starter/ -->
<dependency>
    <groupId>org.yuequan</groupId>
    <artifactId>jpa-soft-delete-spring-boot-starter</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/org.yuequan/jpa-soft-delete-spring-boot-starter/
implementation 'org.yuequan:jpa-soft-delete-spring-boot-starter:1.0.0.RELEASE'
// https://jarcasting.com/artifacts/org.yuequan/jpa-soft-delete-spring-boot-starter/
implementation ("org.yuequan:jpa-soft-delete-spring-boot-starter:1.0.0.RELEASE")
'org.yuequan:jpa-soft-delete-spring-boot-starter:jar:1.0.0.RELEASE'
<dependency org="org.yuequan" name="jpa-soft-delete-spring-boot-starter" rev="1.0.0.RELEASE">
  <artifact name="jpa-soft-delete-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.yuequan', module='jpa-soft-delete-spring-boot-starter', version='1.0.0.RELEASE')
)
libraryDependencies += "org.yuequan" % "jpa-soft-delete-spring-boot-starter" % "1.0.0.RELEASE"
[org.yuequan/jpa-soft-delete-spring-boot-starter "1.0.0.RELEASE"]

Dependencies

compile (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-data-jpa jar 2.0.5.RELEASE

test (3)

Group / Artifact Type Version
com.h2database : h2 jar 1.4.197
org.springframework.boot : spring-boot-starter-test jar 2.0.5.RELEASE
org.liquibase : liquibase-core jar 3.5.5

Project Modules

There are no modules declared in this project.

What does this do?

A simple JPA spring-boot-starter to add conventions for flagging records as discarded.

Usage

Add a maven dependency to your pom.xml

<dependency>
  <groupId>org.yuequan</groupId>
  <artifactId>jpa-soft-delete-spring-boot-starter</artifactId>
  <version>1.0.0.RELEASE</version>
</dependency>

Add @EnableJpaSoftDeleteRepositories annotation to your in application class

@SpringBootApplication
@EnableJpaSoftDeleteRepositories
public class JpaSoftDeleteSpringBootStarterApplication {
    public static void main(String[] args){
        SpringApplication.run(JpaSoftDeleteSpringBootStarterApplication.class, args);
    }
}

Add @SoftDelete annotation to your in repository class

@SoftDelete
public interface UserRepository extends JpaRepository<T, ID> {
    
}

Add removed_at column to your table and add removedAt to your entity, will support customization in the next release

userRepository.delete(user);   
// update users set removed_at=? where id=1

userRepository.findById(user.getId())
// select .... from users user0_ where user0_.id=.. and (user0_.removed_at is null)
    
userRepository.findAll(PageRequest.of(0, count))
// select .... from users user0_ where user0_.removed_at is null limit ?

Versions

Version
1.0.0.RELEASE