Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Jul 23, 2024
1 parent 1f247d5 commit fb4dc37
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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

}

Expand Down

0 comments on commit fb4dc37

Please sign in to comment.