hibernate

java
package com.example.demo.repository;

import com.example.demo.model.User;
import org.springframework.data.jpa.domain.Specification;

import javax.persistence.criteria.Predicate;

Spring Data JPA repository patterns

java spring-data jpa
by David Kumar 2 tabs
java
@MappedSuperclass
@FilterDef(
    name = "tenantFilter",
    parameters = @ParamDef(name = "tenantId", type = String.class)
)
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")

Enforce Multi-Tenant Row Isolation With Hibernate @Filter Enabled Per Request in Spring Boot

spring-boot hibernate jpa
by codesnips 4 tabs
java
package com.shop.inventory;

import jakarta.persistence.*;

@Entity
@Table(name = "inventory_item")

Optimistic Locking on Inventory Updates with @Version and a Retrying Conflict Handler in Spring Boot

spring-boot jpa hibernate
by codesnips 3 tabs
java
package com.example.users.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;

Mapping JPA Entities to DTOs with a MapStruct Mapper Injected into a Spring Service

spring-boot mapstruct dto
by codesnips 4 tabs
java
package com.shop.orders;

import jakarta.persistence.*;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.ArrayList;

Mapping a JPA Entity to a Response DTO with MapStruct in Spring Boot

spring-boot jpa mapstruct
by codesnips 4 tabs
java
package com.example.feed;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Base64;

Keyset (Cursor) Pagination with Spring Data JPA and Base64 Cursors

spring spring-data jpa
by codesnips 3 tabs
java
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.Instant;

Nightly Cleanup of Expired Refresh Tokens with Spring @Scheduled and a Bulk Delete Query

spring-boot scheduling cron
by codesnips 4 tabs
java
package com.example.audit.config;

import java.util.Optional;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;

Automatic JPA Auditing in Spring Boot with @CreatedDate and @LastModifiedBy

spring-boot spring-data-jpa auditing
by codesnips 4 tabs
java
package com.example.docs.domain;

import jakarta.persistence.*;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

Soft-Delete JPA Entities with Hibernate @SQLDelete and @Where Filtering

spring-boot hibernate jpa
by codesnips 3 tabs
java
@Entity
@Table(name = "stored_files")
public class StoredFile {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)

Spring Boot Multipart File Upload with Metadata Persistence and Validation

spring-boot multipart file-upload
by codesnips 3 tabs
java
package com.shop.catalog;

import org.springframework.data.jpa.domain.Specification;

import java.math.BigDecimal;

Dynamic Product Filtering with JPA Specifications from Optional Query Params

spring-boot jpa specifications
by codesnips 4 tabs
java
@Entity
@Table(name = "invoices")
@FilterDef(
    name = "tenantFilter",
    parameters = @ParamDef(name = "tenantId", type = String.class)
)

Per-Tenant Row Filtering with Hibernate @Filter Enabled Per Request

hibernate jpa multi-tenancy
by codesnips 4 tabs