tudose-spring-data-hibernate

Provides Tudose's frameworks for JPA, Hibernate, and Spring Data persistence design decisions.

Updated Jul 28, 2026
One-click install
npx skills add https://github.com/zademy/book-to-skill-zademy --skill tudose-spring-data-hibernate-zademy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tudose-spring-data-hibernate
Source: https://github.com/zademy/book-to-skill-zademy/tree/main/.agents/skills/tudose-spring-data-hibernate
Command: npx skills add https://github.com/zademy/book-to-skill-zademy --skill tudose-spring-data-hibernate-zademy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Java persistence work involves recurring hard decisions — inheritance mapping strategies, fetch plans, locking recipes, identifier generators, and technology selection between Spring Data JPA, JDBC, REST, MongoDB, and Querydsl. This Skill packages the frameworks and decision rules from Cătălin Tudose's "Java Persistence with Spring Data and Hibernate" so an agent can answer these questions with book-grounded guidance instead of generic advice. ## Core Features & Use Cases - Core frameworks loaded by default: paradigm mismatch, lazy-global fetch discipline, READ_COMMITTED + @Version concurrency, entity states and business-key equality, identifier and value-type mapping, and the inheritance decision rule. - Chapter and topic indexes: 20 chapter summaries plus a topic index route questions like "optimistic locking" or "ch11" to the right chapter file for deeper reading. - Supporting references: a glossary of key terms, 15 concrete patterns (enhanced-sequence ids, link entities, Envers auditing, Querydsl Q-types, transactional test rollback), and a cheatsheet of decision tables, thresholds, and code smells. - Use Case: Ask "how do I fix n+1 selects on a Spring Data repository" and receive the book's layered answer — global LAZY mappings, @BatchSize or SUBSELECT safety nets, and per-query join fetch or entity graphs. ## Quick Start Ask the agent how to map an inheritance hierarchy or fix an n+1 query problem using Tudose's Spring Data and Hibernate guidance.

Frequently Asked Questions about tudose-spring-data-hibernate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix the n+1 selects problem in Hibernate?▼

Keep all associations LAZY globally, then fix n+1 per use case with a join fetch JPQL query, an entity graph, @BatchSize(N), or @Fetch(SUBSELECT). Do not flip mappings to EAGER, and never eager-fetch two collections at once, which causes a Cartesian product.

Which JPA inheritance mapping strategy should I use?▼

Use TABLE_PER_CLASS when no polymorphism is needed, SINGLE_TABLE when subclasses differ mainly in behavior (accepting nullable columns), and JOINED when subclasses hold significant data requiring NOT NULL constraints. Benchmark JOINED versus TABLE_PER_CLASS unions with realistic data.

What is the recommended concurrency strategy for JPA entities?▼

The default recipe is READ_COMMITTED isolation plus optimistic locking with a numeric @Version field, giving first-commit-wins semantics without holding locks. Escalate to OPTIMISTIC_FORCE_INCREMENT for aggregate roots or PESSIMISTIC_WRITE only for hot rows.

Spring Data JPA vs Spring Data JDBC — which should I choose?▼

Choose Spring Data JPA for full JPA power, derived queries, and productivity. Choose Spring Data JDBC for simple aggregates when you want predictable SQL without a persistence context — no lazy loading, dirty checking, caching, or JPQL — using its own annotations, never JPA's.

Why should equals and hashCode use a business key instead of the id?▼

The generated id is null before flush, so id-based equality breaks for transient instances, and default identity equality breaks across persistence contexts. Implement equals and hashCode on an immutable unique business key using instanceof and getters for proxy safety.

What topics does this skill not cover?▼

The skill covers only the book's content: Spring Data and Hibernate persistence patterns as taught by Tudose. Topics beyond the book, such as reactive R2DBC or Hibernate Reactive, are out of scope and require other resources.