Hibernate
Hibernate
Hibernate
DataSource-proxy/P6spy
@Bean
public DataSource dataSource() {
SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
return ProxyDataSourceBuilder
.create(actualDataSource())
.name(DATA_SOURCE_PROXY_NAME)
.listener(loggingListener)
.build();
}
--------------------------------------------------------------------------
<dependency>
<groupId>io.hypersistence</groupId>
<artifactId>hypersistence-optimizer</artifactId>
<version>${hypersistence-optimizer.version}</version>
</dependency>
@Test
public void testNoPerformanceIssues() {
HypersistenceOptimizer hypersistenceOptimizer = new HypersistenceOptimizer(
new JpaConfig(entityManagerFactory())
);
assertTrue(hypersistenceOptimizer.getEvents().isEmpty());
}
ERROR [main]: Hypersistence Optimizer - CRITICAL
- EagerFetchingEvent
- The [post] attribute in the [io.hypersistence.optimizer.config.PostComment]
entity
uses eager fetching. Consider using a lazy fetching which,
not only that is more efficient, but it is way more flexible
when it comes to fetching data.
For more info about this event, check out this User Guide link
- https://vladmihalcea.com/hypersistence-optimizer/docs/user-
guide/#EagerFetchingEvent
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at
io.hypersistence.optimizer.config.FailFastOnPerformanceIssuesTest.testNoPerformance
Issues(FailFastOnPerformanceIssuesTest.java:41)
==========================================================
spring.jpa.properties.hibernate.session.events.log.LOG_QUERIES_SLOWER_THAN_MS=25
==============================================================
“Hibernate : Mistakes to avoid” https://link.medium.com/AfVzxBvXj5