From fb4dc376e4fa9baa018d05cab414e1426bc794b9 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Mon, 22 Jul 2024 10:45:24 -0500 Subject: [PATCH] Recreate https://github.com/OpenLiberty/open-liberty/issues/28909 --- .../jpa/data/tests/models/Box.java | 39 ++++++++++++++++++ .../tests/web/JakartaDataRecreateServlet.java | 40 ++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/models/Box.java diff --git a/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/models/Box.java b/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/models/Box.java new file mode 100644 index 000000000000..1c893bd4acbe --- /dev/null +++ b/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/models/Box.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2024 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package io.openliberty.jpa.data.tests.models; + +/** + * Recreate from Jakarta Data TCK + */ +@jakarta.persistence.Entity +public class Box { + @jakarta.persistence.Id + public String boxIdentifier; + + public int length; + + public int width; + + public int height; + + public static Box of(String id, int length, int width, int height) { + Box box = new Box(); + box.boxIdentifier = id; + box.length = length; + box.width = width; + box.height = height; + return box; + } + + @Override + public String toString() { + return "Box@" + Integer.toHexString(hashCode()) + ":" + length + "x" + width + "x" + height + ":" + boxIdentifier; + } +} diff --git a/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/web/JakartaDataRecreateServlet.java b/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/web/JakartaDataRecreateServlet.java index be1e82b79614..c2da2c8aa1af 100644 --- a/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/web/JakartaDataRecreateServlet.java +++ b/dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/web/JakartaDataRecreateServlet.java @@ -24,6 +24,7 @@ import componenttest.app.FATServlet; import io.openliberty.jpa.data.tests.models.AsciiCharacter; +import io.openliberty.jpa.data.tests.models.Box; import io.openliberty.jpa.data.tests.models.Coordinate; import io.openliberty.jpa.data.tests.models.NaturalNumber; import io.openliberty.jpa.data.tests.models.Person; @@ -138,7 +139,7 @@ public void testOLGH28908() throws Exception { .setParameter("ssn", p.ssn_id) .executeUpdate(); - result = em.createQuery("SELECT Person WHERE ssn_id=:ssn", Person.class) + result = em.createQuery("SELECT Person WHERE ssn_id = :ssn", Person.class) .setParameter("ssn", p.ssn_id) .getSingleResult(); @@ -263,6 +264,43 @@ public void testOLGH28920() throws Exception { @Test @Ignore("Reference issue: https://github.com/OpenLiberty/open-liberty/issues/28909") public void testOLGH28909() throws Exception { + Box cube = Box.of("testOLGH28909", 1, 1, 1); + + Box wall; //box with no width + + tx.begin(); + em.persist(cube); + tx.commit(); + + tx.begin(); + try { + em.createQuery("UPDATE Box SET length = length + ?1, width = width - ?1, height = height * ?2") + .setParameter(1, 1) + .setParameter(2, 2) + .executeUpdate(); + + wall = em.createQuery("SELECT Box WHERE boxIdentifier = :id", Box.class) + .setParameter("id", "testOLGH28909") + .getSingleResult(); + + tx.commit(); + } catch (Exception e) { + tx.rollback(); + + /* + * Recreate + * Exception Description: Syntax error parsing [UPDATE Box SET length = length + ?1, width = width - ?1, height = height * ?2]. + * [30, 30] The left parenthesis is missing from the LENGTH expression. + * [45, 50] The left expression is not an arithmetic expression. + * [66, 72] The left expression is not an arithmetic expression. + */ + throw e; + } + + assertEquals("testOLGH28909", wall.boxIdentifier); + assertEquals(2, wall.length); // 1+1 + assertEquals(0, wall.length); // 1-1 + assertEquals(2, wall.height); // 1*2 }