Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ This library provides several benefits:
##### Maven

Add the dependency to your project inside your `pom.xml` file with the right version

```xml

<dependency>
<groupId>com.yannbriancon</groupId>
<artifactId>spring-hibernate-query-utils</artifactId>
<version>X.X.X</version>
<groupId>com.sipios</groupId>
<artifactId>spring-hibernate-query-utils</artifactId>
<version>X.X.X</version>
</dependency>
```

Expand Down Expand Up @@ -149,8 +151,8 @@ class NPlusOneQueriesLoggingTest {

LoggingEvent loggingEvent = loggingEventCaptor.getAllValues().get(0);
assertThat(loggingEvent.getMessage())
.contains("N+1 queries detected on a getter of the entity com.yannbriancon.utils.entity.User\n" +
" at com.yannbriancon.interceptor.NPlusOneQueriesLoggingTest." +
.contains("N+1 queries detected on a getter of the entity com.sipios.utils.entity.User\n" +
" at com.sipios.interceptor.NPlusOneQueriesLoggingTest." +
"lambda$hibernateQueryInterceptor_isDetectingNPlusOneQueriesWhenMissingEagerFetchingOnQuery$0");
assertThat(Level.ERROR).isEqualTo(loggingEvent.getLevel());
}
Expand Down Expand Up @@ -188,8 +190,8 @@ void nPlusOneQueriesDetection_throwsExceptionWhenSessionIsCleared() {
assert false;
} catch (NPlusOneQueriesException exception) {
assertThat(exception.getMessage())
.contains("N+1 queries detected on a getter of the entity com.yannbriancon.utils.entity.User\n" +
" at com.yannbriancon.interceptor.NPlusOneQueriesExceptionTest" +
.contains("N+1 queries detected on a getter of the entity com.sipios.utils.entity.User\n" +
" at com.sipios.interceptor.NPlusOneQueriesExceptionTest" +
".getMessageAuthorNameWithNPlusOneQuery");
}
}
Expand Down Expand Up @@ -252,30 +254,30 @@ Example in a test:

```java
...
import com.yannbriancon.interceptor.HibernateQueryInterceptor;
import com.sipios.interceptor.HibernateQueryInterceptor;


@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class NotificationResourceIntTest {
@Autowired
private HibernateQueryInterceptor hibernateQueryInterceptor;

@Test
public void getNotification_isOk() throws Exception {
// Initialize the query to 0 and allow the counting
hibernateQueryInterceptor.startQueryCount();

// Call the resource that we want to test
MvcResult result = mvc.perform(get("/rest/notifications"))
.andExpect(status().isOk())
.andReturn();

// Get the query count for this thread and check that it is equal to the number of query you expect,
// Let's say 4 for the example.
Assertions.assertThat(hibernateQueryInterceptor.getQueryCount()).isEqualTo(4);
}
@Autowired
private HibernateQueryInterceptor hibernateQueryInterceptor;

@Test
public void getNotification_isOk() throws Exception {
// Initialize the query to 0 and allow the counting
hibernateQueryInterceptor.startQueryCount();

// Call the resource that we want to test
MvcResult result = mvc.perform(get("/rest/notifications"))
.andExpect(status().isOk())
.andReturn();

// Get the query count for this thread and check that it is equal to the number of query you expect,
// Let's say 4 for the example.
Assertions.assertThat(hibernateQueryInterceptor.getQueryCount()).isEqualTo(4);
}
}
```

Expand Down
28 changes: 11 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.yannbriancon</groupId>
<groupId>com.sipios</groupId>
<artifactId>spring-hibernate-query-utils</artifactId>
<version>2.0.0</version>
<version>3.0.0</version>
<packaging>jar</packaging>

<name>spring-hibernate-query-utils</name>
<description>Library giving tools to detect N+1 queries and count the queries generated with Spring and
Hibernate
Fork from https://github.com/yannbriancon/spring-hibernate-query-utils
</description>
<url>https://github.com/yannbriancon/spring-hibernate-query-utils</url>

<developers>
<developer>
<name>Yann Briançon</name>
<email>[email protected]</email>
</developer>
</developers>
<url>https://github.com/sipios/spring-hibernate-query-utils</url>

<licenses>
<license>
Expand All @@ -30,9 +24,9 @@
</licenses>

<scm>
<url>https://github.com/yannbriancon/spring-hibernate-query-utils</url>
<connection>scm:git:[email protected]:yannbriancon/spring-hibernate-query-utils.git</connection>
<developerConnection>scm:git:[email protected]:yannbriancon/spring-hibernate-query-utils.git</developerConnection>
<url>https://github.com/sipios/spring-hibernate-query-utils</url>
<connection>scm:git:[email protected]:sipios/spring-hibernate-query-utils.git</connection>
<developerConnection>scm:git:[email protected]:sipios/spring-hibernate-query-utils.git</developerConnection>
</scm>

<properties>
Expand All @@ -42,7 +36,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<version>2.2.13.RELEASE</version>
<relativePath/> <!-- lookup parent from entity -->
</parent>

Expand Down Expand Up @@ -100,7 +94,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -113,7 +107,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.4.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -126,7 +120,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yannbriancon.config;
package com.sipios.config;

import com.yannbriancon.interceptor.HibernateQueryInterceptor;
import com.sipios.interceptor.HibernateQueryInterceptor;
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.config;
package com.sipios.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.exception;
package com.sipios.exception;

/**
* Exception triggered when detecting N+1 queries
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yannbriancon.interceptor;
package com.sipios.interceptor;

import com.yannbriancon.config.NPlusOneQueriesDetectionProperties;
import com.yannbriancon.exception.NPlusOneQueriesException;
import com.sipios.config.NPlusOneQueriesDetectionProperties;
import com.sipios.exception.NPlusOneQueriesException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Transaction;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.interceptor;
package com.sipios.interceptor;

class SelectQueriesInfo {
private final String initialSelectQuery;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yannbriancon.config.HibernatePropertiesConfig
com.sipios.config.HibernatePropertiesConfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon;
package com.sipios;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yannbriancon.interceptor;
package com.sipios.interceptor;

import com.yannbriancon.utils.entity.Message;
import com.yannbriancon.utils.repository.MessageRepository;
import com.sipios.utils.entity.Message;
import com.sipios.utils.repository.MessageRepository;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.yannbriancon.interceptor;

import com.yannbriancon.exception.NPlusOneQueriesException;
import com.yannbriancon.utils.entity.Message;
import com.yannbriancon.utils.entity.User;
import com.yannbriancon.utils.repository.AvatarRepository;
import com.yannbriancon.utils.repository.MessageRepository;
import com.yannbriancon.utils.repository.UserRepository;
package com.sipios.interceptor;

import com.sipios.exception.NPlusOneQueriesException;
import com.sipios.utils.entity.Message;
import com.sipios.utils.entity.User;
import com.sipios.utils.repository.AvatarRepository;
import com.sipios.utils.repository.MessageRepository;
import com.sipios.utils.repository.UserRepository;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.yannbriancon.interceptor;
package com.sipios.interceptor;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import com.yannbriancon.utils.entity.Message;
import com.yannbriancon.utils.entity.Post;
import com.yannbriancon.utils.repository.MessageRepository;
import com.yannbriancon.utils.repository.PostRepository;
import com.sipios.utils.entity.Message;
import com.sipios.utils.entity.Post;
import com.sipios.utils.repository.MessageRepository;
import com.sipios.utils.repository.PostRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.yannbriancon.interceptor;
package com.sipios.interceptor;

import com.yannbriancon.utils.entity.User;
import com.yannbriancon.utils.repository.MessageRepository;
import com.yannbriancon.utils.repository.UserRepository;
import com.sipios.utils.entity.User;
import com.sipios.utils.repository.MessageRepository;
import com.sipios.utils.repository.UserRepository;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.utils.entity;
package com.sipios.utils.entity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.utils.entity;
package com.sipios.utils.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.utils.entity;
package com.sipios.utils.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yannbriancon.utils.entity;
package com.sipios.utils.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yannbriancon.utils.repository;
package com.sipios.utils.repository;

import com.yannbriancon.utils.entity.Avatar;
import com.sipios.utils.entity.Avatar;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yannbriancon.utils.repository;
package com.sipios.utils.repository;

import com.yannbriancon.utils.entity.Message;
import com.sipios.utils.entity.Message;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yannbriancon.utils.repository;
package com.sipios.utils.repository;

import com.yannbriancon.utils.entity.Post;
import com.sipios.utils.entity.Post;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yannbriancon.utils.repository;
package com.sipios.utils.repository;

import com.yannbriancon.utils.entity.User;
import com.sipios.utils.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
1 change: 1 addition & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=test
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.hbm2ddl.import_files_sql_extractor=org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
spring.jpa.show-sql=true