How do you implement declarative transactions in Spring applications?
Configure Spring transaction management in Boot or plain Spring, handle several data sources, and use TransactionalEventListener for post-commit work.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Configure Spring transaction management in Boot or plain Spring, handle several data sources, and use TransactionalEventListener for post-commit work.
Spring Boot auto-configures the transaction manager, so @Transactional on service methods is usually enough. Learn rollback rules, propagation and pitfalls.
PlatformTransactionManager defines how Spring begins, commits and rolls back transactions. Compare its implementations and see how @Transactional uses it.
Extend AbstractPlatformTransactionManager, bind your resource to the thread and register the manager so @Transactional works for a custom data source.
@Transactional comes from Spring, not Hibernate. See how it controls the Session, dirty checking, lazy loading and rollback in a Hibernate app.
Build a gRPC client in Spring Boot with generated stubs, a shared ManagedChannel, deadlines, error handling and streaming, using the official grpc-java libraries.
Use H2 as an in-memory database with Hibernate in Spring Boot for development and tests, including properties, jakarta entities and a repository test.
In Hibernate, @Entity is the standard Jakarta Persistence annotation that maps a class to a table and puts instances under Session management and dirty checking.
Set spring.jpa.hibernate.ddl-auto to let Hibernate create, update or validate tables from your entities, and learn why production needs migrations.
hibernate.hbm2ddl.auto lets Hibernate create, update or validate your schema at startup. See what each value does and what to use in production.
Which spring.jpa and spring.datasource properties to set for Hibernate in Spring Boot 3, from schema generation and SQL logging to pool tuning.
There is no @SqlFunction annotation in Hibernate. See the supported ways to add custom SQL functions to HQL: FunctionContributor, function() and @Formula.
Register custom SQL functions in Hibernate 6 using FunctionContributor, registerPattern and registerNamed, and call them from HQL, JPQL and Spring Data repositories.
@GrpcService registers a gRPC implementation with the embedded server. See a full example, its configuration and the official Spring gRPC alternative.
Define a proto contract, generate stubs, implement the service as a Spring bean and add the Spring gRPC starter. Covers ports, interceptors and testing.
There is no official spring-boot-starter-grpc. Learn what Spring gRPC and the community starter do and how to build a gRPC service with Spring Boot.
Learn gRPC with Spring Boot: proto definitions, stub generation, a server and client example, deadlines, error handling and when to prefer REST.
Spring Boot does not auto-configure WebSocketStompClient. See how to create it, test a STOMP endpoint with a real client and run it as a service-to-service client.
Build STOMP and raw WebSocket clients in Spring Boot with working code for connecting, subscribing, sending messages, authentication headers and reconnects.
Run Spring Boot on a random port and connect real WebSocket or STOMP clients, collecting messages in a BlockingQueue for reliable assertions.