Add Hibernate 7 batches 2-6, batch 7, and batch 8: mapping styles, JPA annotations, natural IDs, @Immutable, stored procedures, in-memory test databases, JNDI mocking, proxies, associations, temporal mapping, named queries, HQL, Criteria API, EntityManager bootstrapping, Ehcache 3 L2 cache configuration, HikariCP connection pooling, Hibernate Validator CDI integration, aggregate functions, sorting, pagination, interceptors, and Hibernate Search 8 (Hibernate 7.4.5.Final + Spring Boot 4.1.1 + JDK 25)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.ankurm.hibernatedemo.proxy;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Test-only support for docs/11-proxies-and-lazy-initialization.md's OSIV chapter (OsivMaskingTest). Deliberately
|
||||
* uses the container-managed, request/transaction-synchronized {@link EntityManager} (via
|
||||
* {@code @PersistenceContext}), not a manually created one -- open-in-view only has anything
|
||||
* to bind to the request thread when the shared, Spring-managed EntityManager is the one in
|
||||
* play.
|
||||
*/
|
||||
@Service
|
||||
public class OsivBookService {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public ProxyBook findBook(Long id) {
|
||||
// Deliberately does NOT touch getReviews() here -- whether that succeeds later, during
|
||||
// JSON serialization in the web layer, is exactly the thing under test.
|
||||
return entityManager.find(ProxyBook.class, id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user