Skip to content
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
2 changes: 1 addition & 1 deletion webapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11.0.3-jre-stretch
FROM amazoncorretto:16.0.1-alpine
MAINTAINER Hung Tran <tmhung88@outlook.com>
VOLUME /tmp
ARG JAR_FILE
Expand Down
18 changes: 15 additions & 3 deletions webapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mealtracker</groupId>
Expand All @@ -15,7 +15,7 @@
<description>One stop solution to keep track of your meals</description>

<properties>
<java.version>11</java.version>
<java.version>15</java.version>
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
</properties>

Expand Down Expand Up @@ -71,10 +71,22 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>1.14.3</version>
<version>1.15.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
7 changes: 7 additions & 0 deletions webapi/src/integration-test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ spring:
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}

logging:
level:
org.hibernate.SQL: OFF
org.hibernate.type: OFF
org.springframework:
test.context.jdbc.SqlScriptsTestExecutionListener: DEBUG
3 changes: 2 additions & 1 deletion webapi/src/main/java/com/mealtracker/config/JpaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableAutoConfiguration
@EntityScan(basePackages = {"com.mealtracker.domains"})
@EntityScan(basePackages = {"com.mealtracker.domains"}, basePackageClasses = { Jsr310JpaConverters.class })
@EnableJpaRepositories(basePackages = {"com.mealtracker.repositories"})
@EnableTransactionManagement
public class JpaConfig {
Expand Down
4 changes: 2 additions & 2 deletions webapi/src/main/java/com/mealtracker/domains/Meal.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class Meal implements Ownable {
@Column(name = "name")
private String name;

@Column(name = "consumed_date", nullable = false)
@Column(name = "consumed_date", nullable = false, columnDefinition = "DATE")
private LocalDate consumedDate;

@Column(name = "consumed_time", nullable = false)
@Column(name = "consumed_time", nullable = false, columnDefinition = "TIME")
private LocalTime consumedTime;

@Column(name = "calories", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface MealRepository extends PagingAndSortingRepository<Meal, Long> {

List<Meal> findMealByConsumedDateAndConsumerAndDeleted(LocalDate date, User consumer, boolean deleted);

@Query("SELECT meal FROM Meal meal WHERE meal.consumer.id = :consumerId AND deleted = false " +
@Query("SELECT meal FROM Meal meal WHERE meal.consumer.id = :consumerId AND meal.deleted = false " +
"AND (:fromDate IS NULL OR :fromDate <= meal.consumedDate) " +
"AND (:toDate IS NULL OR :toDate > meal.consumedDate) " +
"AND (:fromTime IS NULL OR :fromTime <= meal.consumedTime) " +
Expand All @@ -37,7 +37,6 @@ Page<Meal> filterMyMeals(@Param("consumerId") long consumerId,
@Param("toTime") LocalTime toTime,
Pageable pageable);


@EntityGraph(value = "Meal.consumer", type = EntityGraph.EntityGraphType.LOAD)
@Query("SELECT meal FROM Meal meal JOIN meal.consumer consumer " +
"WHERE meal.deleted = false AND consumer.deleted = false AND meal.id = :mealId " +
Expand Down
Loading