How do you handle cascading deletes in JPA?
Use CascadeType.REMOVE and orphanRemoval on parents that own their children, or ON DELETE CASCADE in the database, and avoid ALL on shared relationships.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Use CascadeType.REMOVE and orphanRemoval on parents that own their children, or ON DELETE CASCADE in the database, and avoid ALL on shared relationships.
JPA's @Cacheable marks an entity for the Hibernate second-level cache. Learn the cache modes, setup with Ehcache, and how it differs from Spring's annotation.
Understand the JPA first-level, second-level and query caches and Spring's @Cacheable. Includes working Hibernate 6 and Ehcache JCache configuration.
Add the ActiveMQ starter and set spring.activemq.broker-url, user and password. Spring Boot then auto-configures JmsTemplate and listeners.
It bundles Spring JMS and ActiveMQ Classic libraries and auto-configures a connection factory and JmsTemplate for asynchronous messaging.
Add the ActiveMQ or Artemis starter, configure the broker URL, send with JmsTemplate and receive with @JmsListener. Covers JSON converters, topics and reliability.
Propagation.REQUIRES_NEW suspends the caller's transaction and runs a method in its own, independently committed transaction.
RedeliveryPolicy configures how Apache Camel retries failed messages, including attempts, delay, exponential backoff, jitter and dead letter handling.
Call stored procedures from JPA and Spring Data JPA with @Procedure, named procedures and StoredProcedureQuery, including OUT parameters.
Configure redelivery, exponential backoff and a dead letter channel in Apache Camel routes using onException and error handlers.
@Procedure lets a Spring Data JPA repository call a database stored procedure. See procedureName, OUT parameters, named stored procedure queries and database caveats.
Learn three ways to call stored procedures from JPA and Spring Data, how to map IN and OUT parameters, and when to pick each approach.
@Query lets you define JPQL or native SQL on a Spring Data repository method when derived queries are too limited. See parameters, updates, paging and projections.
Implement search in Spring Data repositories using derived queries, @Query, Specifications and pagination, and learn when to use each approach.
Page carries the content of one page plus total elements and pages. Learn how repositories fill it, how to tune the count query and when to scroll instead.
Accept a Pageable, apply offset, size and sort to your query, and return a Page with PageableExecutionUtils in a custom repository.
@Repository registers a data access class as a Spring bean and translates persistence exceptions into DataAccessException for technology-neutral handling.
Derive queries from method names, write JPQL or native SQL with @Query, and add custom fragments when you need the EntityManager. Spring Boot 3 examples.
JpaRepository adds CRUD, paging, sorting, flush and batch operations to a Spring Data interface with no implementation. See its methods and query options.
onException() lets Apache Camel routes retry, handle or redirect failures per exception type. See handled, continued, backoff and scope with working examples.