From a203c4fb130dd588a57fef306754759697fbc98d Mon Sep 17 00:00:00 2001 From: Nazar Klimovych Date: Thu, 18 Apr 2024 13:57:32 +0300 Subject: [PATCH] Removed redundant pom.xml repositories property, in BookRepositoryImpl class, in method findAll changed implementation from criteriaQuery to session.createQuery(). Also removed database-platform in application.properties --- pom.xml | 8 -------- .../bookstore/repository/impl/BookRepositoryImpl.java | 6 +----- src/main/resources/application.properties | 1 - 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 8217dab..2757cd3 100644 --- a/pom.xml +++ b/pom.xml @@ -101,12 +101,4 @@ - - - maven_central - Maven Central - https://repo.maven.apache.org/maven2/ - - - diff --git a/src/main/java/mate/academy/bookstore/repository/impl/BookRepositoryImpl.java b/src/main/java/mate/academy/bookstore/repository/impl/BookRepositoryImpl.java index aeb4450..9a9ceb0 100644 --- a/src/main/java/mate/academy/bookstore/repository/impl/BookRepositoryImpl.java +++ b/src/main/java/mate/academy/bookstore/repository/impl/BookRepositoryImpl.java @@ -1,6 +1,5 @@ package mate.academy.bookstore.repository.impl; -import jakarta.persistence.criteria.CriteriaQuery; import java.util.List; import mate.academy.bookstore.exception.DataProcessingException; import mate.academy.bookstore.model.Book; @@ -45,10 +44,7 @@ public Book save(Book book) { @Override public List findAll() { try (Session session = sessionFactory.openSession()) { - CriteriaQuery criteriaQuery = session - .getCriteriaBuilder().createQuery(Book.class); - criteriaQuery.from(Book.class); - return session.createQuery(criteriaQuery).getResultList(); + return session.createQuery("FROM Book", Book.class).getResultList(); } catch (Exception e) { throw new DataProcessingException("Can't find all books", e); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ab8c379..357844b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,6 +4,5 @@ spring.datasource.username=root spring.datasource.password=password spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.show-sql=true