Skip to content

Instantly share code, notes, and snippets.

View MuellerConstantin's full-sized avatar

Constantin Müller MuellerConstantin

View GitHub Profile
@MuellerConstantin
MuellerConstantin / BaseEntity.java
Created February 10, 2023 10:25
Hibernate/JPA base entity which supports soft deletes and keeps deleted records in the database.
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.Type;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.time.Instant;
@MuellerConstantin
MuellerConstantin / AbacPermissionEvaluator.java
Created June 28, 2020 16:15
JSON and SpEL based "Attribute Based Access Control (ABAC)" for the Spring Framework
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.core.Authentication;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@MuellerConstantin
MuellerConstantin / AclClass.java
Last active March 3, 2021 16:33
Spring Data ACL permission filtering support for persistence layer
import lombok.*;
import org.springframework.data.annotation.Immutable;
import javax.persistence.*;
@Entity
@Immutable
@Table(name = "acl_class")
@AllArgsConstructor
@NoArgsConstructor
@MuellerConstantin
MuellerConstantin / EnableMongoData.java
Created November 15, 2019 21:28
Execution listener for loading initial data into MongoDB database
import org.springframework.test.context.TestExecutionListeners;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;