This tutorial demonstrates how to use the open-source Sanitizer-Lib to automatically sanitize sensitive fields in Spring Boot 3.5 applications via the @Sanitize annotation, covering JSON deserialization, JPA persistence, built-in and custom sanitizers, and programmatic registry usage.
This article demonstrates how PostgreSQL's JSONB type combined with Spring Boot provides a practical alternative to MongoDB for managing dynamic custom fields in enterprise applications, covering storage, indexing, JPA mapping, partial updates, querying patterns, and performance tuning while preserving relational integrity.
This article identifies five common MapStruct misuses — complex logic in @Mapping expressions, missing bidirectional relationship handling, over-mapping in hot paths, injecting business services into mappers, and naive PATCH updates — and shows correct Java alternatives for each case.
Spring Data 4.1 introduces type-safe property paths using method references like Sort.by(Order::getCreatedAt) and TypedPropertyPath for nested fields, replacing error-prone string-based sorting with compile-time checks and IDE refactoring support across JPA, JDBC, MongoDB, and other Spring Data modules.
This tutorial demonstrates how to replace auto-increment IDs with UUIDv7 in Spring Boot 3.5 using JPA and MyBatis-Plus, covering UUIDv7's timestamp-based structure, the java-uuid-generator library, and custom identifier generator implementations for both persistence frameworks.
The article demonstrates how Hibernate 7.4, used with Spring Boot 3.5, adds built‑in support for safe pagination of collection fetches, temporal history tables, and native audit tables, all configurable via a single annotation and a few properties, with concrete code examples and runtime screenshots.
Jakarta EE, the rebranded Java EE now governed by the Eclipse Foundation, offers open standards, built‑in enterprise capabilities, cloud‑native improvements, a smooth upgrade path for legacy systems, and familiar APIs, making it an attractive alternative to Spring for long‑term, maintainable applications.
This article reviews six practical approaches—from database column defaults to AOP interceptors—for automatically populating common fields such as timestamps, creator, and tenant IDs in SpringBoot applications, compares their pros, cons, and applicability, and offers guidance on selecting the most suitable solution.
SpringBoot developers can eliminate repetitive manual setting of common fields like create_time, update_time, create_by, and update_by by using six automatic filling solutions—from database default values and MyBatis‑Plus meta‑object handlers to JPA auditing, MyBatis interceptors, AOP aspects, and controller request‑body advice—each with its own pros, cons, and ideal scenarios.
This article provides a comprehensive Spring container walkthrough covering the full lifecycle—from bean definition scanning and proxy creation during startup to request handling, AOP interception, transaction and caching mechanisms—plus detailed answers to 12 common interview questions with code examples and best‑practice recommendations.
This article examines five practical ways to improve Spring Boot 3.5.0 transaction performance—read‑only transactions, explicit propagation settings, correctly sized HikariCP pools, JDBC prepared‑statement caching, and Hibernate batch writes—showing the underlying overhead and providing concrete code and configuration examples.
The article demonstrates how Spring Boot can automatically convert strings to enums for query and path parameters, introduces a unified StringToEnumConverterFactory, configures Jackson for case‑insensitive enum deserialization in @RequestBody, and uses a JPA AttributeConverter to persist enums, removing repetitive manual conversion code.
A batch‑import of 15,000 templates caused a JPQL query with two JOIN FETCH collections to explode into 50 million rows, triggering out‑of‑memory crashes; the article explains why this happens, how the issue was diagnosed, and three concrete fixes that cut rows by nine‑fold and speed up processing fifteen‑fold.
The article explains how a Repository differs from a DAO by focusing on aggregates instead of tables, shows proper interface design, PO‑to‑aggregate mapping, read/write separation, CQRS basics, and JPA pitfalls, providing concrete Java code examples for Spring Boot projects.
The article explains that an Entity is distinguished by a unique identifier while a Value Object is defined solely by its attributes and must be immutable, illustrating the concepts with Java Entity, record, and JPA mapping examples, and providing three practical questions to decide which to use.
This article presents four practical solutions for the Spring Boot 3.5.0 “Could not write JSON: failed to lazily initialize a collection… no Session” error that occurs when serializing bidirectional one-to-many relationships, covering @JsonIgnore, JPQL fetch joins, enabling OpenEntityManagerInView, and using the Jackson Hibernate6 module, with code examples and results.
When bidirectional JPA entities cause infinite JSON recursion in Spring Boot, the article explains why @JsonIgnore is suboptimal and demonstrates four advanced alternatives—@JsonIgnoreProperties, @JsonManagedReference/@JsonBackReference, the Jackson Hibernate module, and @JsonIdentityInfo—each with code samples and runtime results.
This article provides a comprehensive interview self‑test covering JPA, Hibernate, and Spring Data JPA, including entity lifecycle states, repository proxy creation, PartTree method parsing, first‑level cache behavior, dirty checking, transaction binding, N+1 query problems, lazy loading exceptions, JPQL vs native queries, save vs persist differences, and the semantics of findAll returning an empty collection.
This article demonstrates four techniques for persisting flexible JSON data in Spring Boot 3.5.0—using JPA @Convert with AttributeConverter, Hibernate @JdbcTypeCode, a custom MyBatis TypeHandler, and MyBatis‑Plus annotations—complete with code snippets, test cases, and execution results.
The article explains the contract between equals and hashCode in Java, shows what goes wrong when only one is overridden, demonstrates the correct implementation with Objects.equals and Objects.hash, covers IDE/Lombok generation, JPA entity nuances, inheritance pitfalls, records, and common anti‑patterns.
This guide walks through configuring comprehensive logging in Spring Boot 3.5 for eight common scenarios—including JPA SQL, transaction flow, JDBC operations, RestTemplate, RestClient, WebClient, controller requests, and Feign calls—providing concrete code samples, YAML settings, and sample output to help developers troubleshoot and monitor applications effectively.
This article explains how Spring Boot 3.5.0 leverages the @Lock annotation and JPA LockModeType to apply pessimistic read or write locks, shows custom repository implementations, provides concrete code snippets and generated SQL, and emphasizes that all lock operations must run inside a transaction.
This extensive guide redesigns Spring Boot data‑access for high‑traffic e‑commerce, explaining why traditional JPA‑Redis‑Elasticsearch thinking fails, then detailing a multimodal architecture that assigns strong‑consistency, hot‑read, document, and search responsibilities to MySQL, Redis, MongoDB and Elasticsearch, with production‑grade code, CDC pipelines, distributed‑transaction patterns, caching strategies, observability, and cloud‑native deployment.
This article dissects a comprehensive set of Barclays Java Spring Boot microservices interview questions, covering HashMap internals, REST method semantics, code implementations, Spring dependency injection, JDBC evolution, JPA/Hibernate usage, SQL injection defenses, microservice architecture essentials, and best‑practice REST API design.
This article walks through Spring Data JPA interface projections—from basic setup and field aliasing to association queries, closed vs. open projections, pagination, and dynamic use—showing how they eliminate redundant data fetching, improve performance, and avoid common pitfalls.
The article dissects how the default JpaRepository findById method can trigger unnecessary SELECT queries, create foreign‑key violations under concurrency, and degrade performance, then demonstrates three concrete workarounds—including getReferenceById, manual entity construction, and pessimistic read locking—to eliminate these issues.
This tutorial walks through integrating SpringBoot with JPA (Hibernate) from adding dependencies to configuring the datasource, defining entities, using JpaRepository, building service and controller layers, applying method‑naming rules, writing custom queries, comparing JPA with MyBatis and JdbcTemplate, and highlighting key pitfalls for rapid, low‑boilerplate data‑access development.
Spring Boot’s default Open Session in View (OSIV) keeps Hibernate sessions open throughout the request, silently triggering lazy‑loaded queries during JSON serialization, leading to N+1 problems and massive DB load under load, but disabling it and using explicit fetch joins restores performance.
The article explains what Open Session in View (OSIV) is, why keeping a Hibernate Session open for the whole request can silently cause massive N+1 query problems in Spring Boot REST APIs, and provides a concrete example and step‑by‑step solution using explicit fetch joins and disabling OSIV.
This article examines seven frequent performance problems when using Spring Data JPA in Spring Boot 3—such as eager loading, N+1 queries, returning entities from controllers, eager fetch misuse, oversized transactions, count‑heavy pagination, and logging entities—and provides concrete code‑level solutions like DTO projections, EntityGraph, slice pagination, and proper transaction separation.
The article explains why storing sensitive columns in plaintext leaves systems vulnerable even when the database is encrypted, and demonstrates a low‑intrusion, maintainable field‑level encryption solution for Spring Boot using JPA AttributeConverters, including code, pros, cons, and production best practices.
This guide explores eight lesser‑known Hibernate annotations—such as @EntityGraph, @Formula, @SQLRestriction, @SQLDelete, @JoinFormula, @Cache, @DynamicUpdate/Insert, and @Filter/FilterDef—demonstrating how they improve performance, simplify queries, and enhance data handling in Spring Boot 3 applications for developers.
This guide explains why random UUIDs are inefficient as primary keys, introduces the TSID library that creates 64‑bit time‑ordered identifiers, and provides step‑by‑step Maven setup, API usage, JPA integration, and testing examples for Spring Boot 3.5.0.
This article explains the different cache layers—client, application, database, and distributed—provides best‑practice guidelines, and shows how to configure client‑side headers, application‑side caches with Hazelcast, JPA second‑level caching, and JMS‑based cache coordination in GlassFish.
This article compares five practical techniques—custom findBy, Query‑by‑Example, existsBy, COUNT aggregation, and native CASE WHEN EXISTS SQL—to determine whether a database record exists in Spring Boot 3.5.0, providing code examples, generated SQL, performance notes, and recommendations for each approach.
A Spring Boot 3.4.2 tutorial compares four entity‑to‑DTO conversion strategies—manual mapping, MapStruct, JPQL DTO projection, and JPQL record projection—using JMH benchmarks on an H2 in‑memory database, revealing that JPQL projection is roughly three times faster than the other approaches.
This article demonstrates how to integrate Apache Doris, a high‑performance MPP analytical database, into a Spring Boot application as a drop‑in replacement for MySQL, detailing environment setup, Maven dependencies, configuration, entity mapping, repository, service and controller code, and performance testing that shows Doris’s superior real‑time query speed.
This article explains the classic N+1 query issue in Spring Data JPA, demonstrates how JPQL JOIN FETCH and the @EntityGraph annotation can declaratively load associations, and provides advanced examples—including named entity graphs and combining @EntityGraph with custom @Query—to improve performance and code maintainability.
This article explains how Hibernate’s @Formula annotation lets Spring Boot developers define read‑only computed fields directly in entity classes, provides concrete code examples for single‑table calculations, sub‑queries, and conditional logic, and outlines compatibility and performance considerations.
SpringBoot’s out‑of‑the‑box defaults—such as Tomcat’s tiny connection pool, HikariCP’s 10‑thread limit, lazy‑loaded JPA entities, system‑timezone JSON serialization, un‑rolled Logback files, unlimited in‑memory cache, exposed Actuator endpoints, tiny file‑upload limits, per‑task thread creation for @Async, and unlimited transaction timeouts—can silently cripple production systems, so each must be reviewed and tuned for real‑world workloads.
This article explains how to configure and customize Hibernate and Spring Data JPA logging in Spring Boot 3, covering SQL output, formatting, highlighting, comment inclusion, statistics, slow‑query detection, transaction logs, parameter binding, cache logs, and related performance diagnostics.
This article explains the Hibernate @Formula annotation, covering its purpose, basic and advanced usage with code examples, performance considerations, and best practices, while also announcing a Spring Boot 3 PDF collection of 181 practical cases with free ongoing updates.
This article examines the @Transactional annotation in Spring Boot, explains its proper and improper use, and presents extensive performance tests using JPA, JDBC, and EntityManager that reveal surprising cases where transactions improve query throughput.
This article explains how to migrate a Java application from JPA 2.x to Jakarta Persistence 3.0 by updating Maven dependencies, replacing javax.persistence imports with jakarta.persistence, adjusting XML namespace URLs, and renaming configuration properties, all illustrated with concrete code snippets.
This article introduces dynamic SQL techniques for Spring Boot 3, compares JPA and MyBatis implementations, and demonstrates how the powerful jpa-search-helper library simplifies complex queries with both map‑based and JSON‑based modes, including pagination and sorting examples.
This article explains why optimistic locking can fail under high concurrency, demonstrates how to apply database‑level pessimistic locks with Spring Data JPA, configure lock timeouts for MySQL and Oracle, and gracefully handle lock exceptions using Spring Retry.
This tutorial shows how to store, query, and manipulate JSON data in PostgreSQL using JPA and Hibernate, covering native JSON/JSONB types, the Hypersistence JsonType, entity mapping, service and REST layers, WildFly configuration, and curl‑based testing.
This article walks through configuring multiple data sources in Spring Boot 3, covering @Primary usage, YAML datasource definitions, bean setup with DataSourceBuilder, JPA entity manager factories, transaction managers, and unit testing to ensure each datasource operates independently.
Explore 15 practical Java Stream API examples—from filtering and mapping to parallel processing and JPA integration—demonstrating how to write concise, efficient code, improve performance, and avoid memory issues, with full code snippets and explanations for each use case.
This article explains how three Hibernate annotations—@Formula, @SQLRestriction (or @Where), and @Filter—solve common JPA pain points such as scattered query logic, duplicated calculations, and hard‑coded filters, providing code‑reduction, better performance, and easier maintenance in Spring Boot 3 projects.
This article walks through essential Spring Boot 3 JPA entity design techniques—including inheritance, primary‑key mapping, relationship handling, cascade operations, validation, auditing, DTO projection, and index creation—providing clear code examples and configuration tips for building robust, maintainable backend services.
This article announces a Spring Boot 3 case collection with 100 permanent examples and then provides a comprehensive guide on recording SQL statements in Spring Boot applications via JDBC, JPA, MyBatis and the datasource‑proxy library, including configuration snippets, code samples and visual output illustrations.
This article examines the challenges of using JPA optimistic locking for inventory deduction under high concurrency, demonstrates why naive retry logic can cause deadlocks and stale data, and walks through five progressively refined implementations that resolve transaction, caching, and isolation issues.
This article explains the concept and benefits of logical deletion, then demonstrates how to implement it in Spring Boot 3 using JPA annotations like @SQLDelete and @SoftDelete, and MyBatis‑Plus configuration, complete with code examples and SQL output.
Upgrading to Spring Boot 3.3.5 can cause Hibernate to generate table columns in a different order than the fields in your @Entity class, but by copying and adjusting the PropertyContainer class you can restore the original field order and avoid schema inconsistencies.
This article provides a comprehensive guide to data validation in Spring Boot 3, covering Bean Validation annotations, controller and service‑layer checks, JPA entity validation, custom constraints, validation groups, programmatic validation, and internationalized error messages with practical code examples and tests.
This article examines the limitations of using JPA for complex queries in SpringBoot projects and demonstrates how MyBatis‑Flex can simplify conditional queries, partial field selection, Kotlin integration, and code generation through clear code examples and practical guidance.
This article explains why Java ORM frameworks are essential for simplifying database access, outlines the critical criteria for selecting the right ORM, compares popular choices such as Hibernate, JPA, EclipseLink, and DataNucleus, and provides a step‑by‑step guide for successful implementation.
This article explains how Spring's @Transactional(readOnly=true) works, why it can boost performance and reduce memory usage, and examines the trade‑offs of applying it to service‑layer read‑only methods versus repository methods, backed by code examples and connection‑usage tests.
This article introduces MyBatisX, an IDEA plugin that streamlines MyBatis development with navigation, GUI‑based code generation, customizable templates, JPA‑style method hints, and icon settings, providing step‑by‑step instructions and visual examples to enhance backend productivity.
This article explains why a SpringBoot 3.0.9 application creates duplicate user rows when sending confirmation emails, analyzes the transactional behavior causing the issue, and presents three solutions—including pessimistic locking, narrowing transaction scope, and an event‑driven approach—to ensure data consistency.
This article explains how Spring's @Transactional(readOnly = true) works internally, shows the performance and memory advantages it brings, compares service‑layer and repository‑layer usage with concrete connection‑pool tests, and provides guidance on when to apply it in JPA‑based backend applications.
This tutorial explains why auditing is essential, outlines the benefits such as data tracking, security, troubleshooting and compliance, and provides a complete Spring Data JPA implementation with code examples, testing procedures, and required dependencies.
This article explains the concepts of pessimistic and optimistic locking, compares their use cases, demonstrates version‑based and CAS implementations, and shows a complete Spring Boot example with retry‑enabled optimistic lock handling using AOP and custom annotations.
This tutorial provides an in‑depth guide to Spring Boot covering core concepts such as project setup, configuration files, logging frameworks, MVC architecture, CRUD examples, error handling, embedded servlet containers, Docker integration, JDBC/MyBatis/JPA data access, startup process, and how to create custom starter modules.
This tutorial demonstrates how to integrate a custom MyBatis TypeHandler in a Spring Boot 2.6.12 application to automatically encrypt sensitive fields before persisting them to MySQL and decrypt them on retrieval, covering dependencies, configuration, entity definition, encryption utilities, mapper XML, and test cases.
This guide walks through setting up a Spring Boot project with JDK 8, Atomikos, and JPA to manage two MySQL data sources, configure JTA transaction handling, define entity managers, services, and a controller, and demonstrates successful and failing transaction scenarios with code snippets and screenshots.
This tutorial walks through using Spring Batch with Spring Boot 2.6.12 to create a batch job that reads CSV data, processes each record, and writes the results into a MySQL database, covering architecture, configuration, code components, and execution steps.
This guide walks through setting up a Spring Boot 2.4.12 project with JDK 1.8, Oracle, and two data sources—master and slave—covering Maven dependencies, application.yml settings, custom property classes, HikariDataSource beans, JPA EntityManagerFactory, MyBatis SqlSessionFactory, mapper scanning, and testing entity creation to verify successful configuration.
This guide walks through setting up Spring Batch 4.2.7 with Spring Boot 2.4.12, covering architecture, configuration, job, step, reader, processor, writer, listeners, and deployment, demonstrating how to read CSV data, process it, and persist results to a MySQL database.
The article compares JPA and MyBatis in Chinese software projects, argues that JPA excels when solid OOP design and domain modeling are prioritized while MyBatis shines in data‑driven or fast‑delivery scenarios, and illustrates the discussion with Java code examples and design‑pattern reminders.
Learn how to set up a Spring Boot 3.0.9 environment, define entities, repositories, services, and a GraphQL schema, then expose a GraphQL endpoint with sample queries, illustrating complete backend API development using GraphQL and JPA.
This article demonstrates how using Spring Boot's TransactionTemplate to programmatically control transactions can prevent long‑running non‑transactional operations from blocking database connections, thereby increasing system throughput compared to the traditional @Transactional annotation, with detailed code examples and performance observations.
This article compares JPA and MyBatis, discusses when each framework shines, explores design‑driven development approaches, and highlights common pitfalls such as oversized services, neglected OOP principles, and the importance of proper data modeling for large‑scale Java backend projects.
This article explains how to avoid OutOfMemoryError when exporting massive MySQL datasets by streaming data with JPA or MyBatis, writing each record directly to a CSV file, and provides complete Spring Boot code examples, performance comparisons, and deployment tips.
This article explains how to export large MySQL datasets in SpringBoot by streaming data directly to CSV, avoiding full‑memory loads that cause OutOfMemoryError, and provides complete JPA and MyBatis implementations, performance testing, and practical code examples for production use.
This article explains how to export tens of millions of rows from MySQL using Spring Boot by streaming data with JPA or MyBatis, avoiding OutOfMemoryError, switching to CSV format, and provides complete code examples, performance comparison, and tips for generating test data.
The article explains how to prevent OutOfMemoryError when exporting massive MySQL datasets by streaming records with JPA or MyBatis, writing them directly to CSV files, and demonstrates significant memory savings compared to traditional batch export methods.
This article explains Spring's unified transaction model, the @Transactional annotation, and the various propagation and isolation settings, then details ten typical scenarios—such as missing Spring management, final or private methods, internal calls, wrong propagation, multithreading, and unsupported databases—that cause transactions to fail, providing code examples and solutions to avoid each issue.
This guide walks through creating a complete SpringBoot permission management system using SpringSecurity, covering database design, Maven setup, entity classes, security configuration, utility methods, dynamic menu loading, Thymeleaf menu rendering, and testing with role‑based access control.
This guide walks through configuring custom and multiple data sources, using Spring Data repositories, fine‑tuning JPA and Hibernate settings, customizing naming strategies, enabling second‑level caching, and exposing repositories as REST endpoints in a Spring Boot 2.4.13 application.
This tutorial introduces PostgreSQL, compares its advantages over MySQL, shows how to download and install it, and provides a complete Spring Boot integration guide with detailed configuration, entity mapping, repository creation, and unit‑test driven CRUD operations.
The article explains how designing domain models as interfaces, rather than concrete classes, improves flexibility in backend architectures by simplifying data exchange, supporting multiple persistence technologies, and enabling seamless deployment across standalone, clustered, and micro‑service environments.
This article explores comprehensive domain interface design in Java backend development, showing how to model domain objects as interfaces, implement repositories for JPA, MyBatis, and Elasticsearch, handle associations with JPA annotations, and apply these patterns in the open‑source Mallfoundry e‑commerce platform.
This article explains why a caught javax.validation.ConstraintViolationException in a Spring @Transactional method does not stop the transaction from rolling back, and shows how to debug the flow with logs and breakpoints to understand the underlying commit process.
This guide walks through setting up a Spring Boot 2.1.4 application with JDK 1.8, Oracle, and HikariCP to use separate master and slave data sources, covering Maven dependencies, YAML configuration, custom property classes, JPA EntityManager factories, MyBatis SqlSession factories, mapper scanning, and sample entity definitions.
This article examines four Spring Boot @Transactional test cases using a MySQL InnoDB database to determine whether each method rolls back or commits when exceptions are thrown or caught, providing code examples and inviting readers to vote on the outcomes.
This article provides a detailed overview of the most commonly used Spring Boot, Spring MVC, and JPA annotations, explains their purposes, shows how they interact, and includes practical code examples for building robust Java backend applications.
This article provides a concise reference of common SpringBoot and Spring Cloud annotations, JPA entity mappings, global exception handling techniques, and related code examples, helping Java backend developers quickly understand and apply these components in their projects.
This article walks you through setting up the Erupt Java annotation‑based framework, configuring Maven dependencies and datasource, launching a ready‑made admin UI, customizing pages with @Erupt annotations, and extending functionality via data proxies, all without writing front‑end code.
This article compares JDBC Template, MyBatis, JOOQ, Hibernate, and JPA, analyzing their SQL encapsulation, performance, DSL support, cross‑database portability, and security to explain why the author ultimately chose JDBC Template for Java data persistence.
This guide demonstrates step‑by‑step how to transform a Spring Boot application that uses JPA for CRUD operations into a Quarkus‑based microservice, covering Maven dependencies, configuration changes, main class adaptation, and optional extensions such as actuator health checks and Flyway migrations.
This article reviews Java persistence technologies, shows how raw string concatenation in JDBC, MyBatis, JPA/Hibernate and native SQL can lead to SQL injection, and provides concrete safe‑coding patterns such as PreparedStatement, #{ } bindings, named parameters, and dynamic‑SQL safeguards.
This article provides a comprehensive overview of common Spring Boot annotations, including @SpringBootApplication, @RestController, @RequestMapping, and JPA annotations, explaining their purposes, usage, and example code snippets for building Java backend applications effectively.
This article provides a comprehensive overview of essential Spring Boot and Spring MVC annotations—including @SpringBootApplication, @RestController, @RequestMapping, @Autowired, and JPA annotations—explaining their purposes, usage examples, and how they simplify configuration, component scanning, request handling, and database mapping in Java backend development.
This article provides a detailed overview of common Spring Boot, Spring MVC, and JPA annotations—including @SpringBootApplication, @RestController, @RequestMapping, and JPA mapping annotations—explaining their purposes, usage patterns, and example code snippets for building Java backend applications.
This guide walks you through connecting IntelliJ IDEA to a database, using its built‑in POJO generators, adding JPA modules, and creating custom Groovy scripts to produce fully annotated JPA entity classes, complete with getters, setters, and utility methods.
The article provides a step‑by‑step tutorial on configuring database connections in IntelliJ IDEA, using its built‑in tools to generate simple POJOs or JPA‑annotated entities, and creating a custom Groovy script to produce fully annotated Java entity classes directly from a database schema.
The article explains why adding @Transactional in Spring may fail to roll back when MySQL uses the MyISAM engine, shows the required Hibernate dialect configuration for InnoDB, and offers tips for diagnosing similar transaction issues.