From 2a4adf293579f3d8a9b13e18a6a95cda69c75fb7 Mon Sep 17 00:00:00 2001 From: glopez Date: Sun, 4 Aug 2019 21:39:46 -0300 Subject: [PATCH] BAEL-2804 JPA Query Parameters Usage - formatting issues fixed I fixed some formatting issues as requested since the eclipse formatter does not support 4 spaces for blocks a 2 for continuations hence it has to be resolved manually. Additionally I've applied formatting to the logback.xml file. --- .../java-jpa-2/src/main/resources/logback.xml | 19 ++++++++++--------- .../queryparams/JPAQueryParamsUnitTest.java | 14 +++++++------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/main/resources/logback.xml b/persistence-modules/java-jpa-2/src/main/resources/logback.xml index 7d900d8ea8..e0098e7c7e 100644 --- a/persistence-modules/java-jpa-2/src/main/resources/logback.xml +++ b/persistence-modules/java-jpa-2/src/main/resources/logback.xml @@ -1,13 +1,14 @@ - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + - - - + + + \ No newline at end of file diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/queryparams/JPAQueryParamsUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/queryparams/JPAQueryParamsUnitTest.java index 4f320935cf..55ee0e6e59 100644 --- a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/queryparams/JPAQueryParamsUnitTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/queryparams/JPAQueryParamsUnitTest.java @@ -36,7 +36,7 @@ public class JPAQueryParamsUnitTest { TypedQuery query = entityManager.createQuery("SELECT e FROM Employee e WHERE e.empNumber = ?1", Employee.class); String empNumber = "A123"; Employee employee = query.setParameter(1, empNumber) - .getSingleResult(); + .getSingleResult(); Assert.assertNotNull("Employee not found", employee); } @@ -45,7 +45,7 @@ public class JPAQueryParamsUnitTest { TypedQuery query = entityManager.createQuery("SELECT e FROM Employee e WHERE e.empNumber IN (?1)", Employee.class); List empNumbers = Arrays.asList("A123", "A124"); List employees = query.setParameter(1, empNumbers) - .getResultList(); + .getResultList(); Assert.assertNotNull("Employees not found", employees); Assert.assertFalse("Employees not found", employees.isEmpty()); } @@ -55,7 +55,7 @@ public class JPAQueryParamsUnitTest { TypedQuery query = entityManager.createQuery("SELECT e FROM Employee e WHERE e.empNumber = :number", Employee.class); String empNumber = "A123"; Employee employee = query.setParameter("number", empNumber) - .getSingleResult(); + .getSingleResult(); Assert.assertNotNull("Employee not found", employee); } @@ -64,7 +64,7 @@ public class JPAQueryParamsUnitTest { TypedQuery query = entityManager.createQuery("SELECT e FROM Employee e WHERE e.empNumber IN (:numbers)", Employee.class); List empNumbers = Arrays.asList("A123", "A124"); List employees = query.setParameter("numbers", empNumbers) - .getResultList(); + .getResultList(); Assert.assertNotNull("Employees not found", employees); Assert.assertFalse("Employees not found", employees.isEmpty()); } @@ -75,8 +75,8 @@ public class JPAQueryParamsUnitTest { String empName = "John Doe"; int empAge = 55; List employees = query.setParameter("name", empName) - .setParameter("empAge", empAge) - .getResultList(); + .setParameter("empAge", empAge) + .getResultList(); Assert.assertNotNull("Employees not found!", employees); Assert.assertTrue("Employees not found!", !employees.isEmpty()); } @@ -89,7 +89,7 @@ public class JPAQueryParamsUnitTest { Root c = cQuery.from(Employee.class); ParameterExpression paramEmpNumber = cb.parameter(String.class); cQuery.select(c) - .where(cb.equal(c.get(Employee_.empNumber), paramEmpNumber)); + .where(cb.equal(c.get(Employee_.empNumber), paramEmpNumber)); TypedQuery query = entityManager.createQuery(cQuery); String empNumber = "A123";