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 8f08689 commit aaa483c
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
*
*/
package io.openliberty.jpa.data.tests.models;

import java.util.ArrayList;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;

/**
* Recreate from io.openliberty.data.internal_fat
*/
@Entity
public class Prime {
public String binaryDigits;

public boolean even;

public String hex;

public String name;

@Id
public long numberId;

public String romanNumeral;

public ArrayList<String> romanNumeralSymbols;

public int sumOfBits;

public static Prime of(long number, String romanNumeral, String name) {
Prime inst = new Prime();
inst.binaryDigits = Long.toBinaryString(number);
inst.even = number % 2 == 0;
inst.hex = Long.toHexString(number);
inst.name = name;
inst.romanNumeral = romanNumeral;
inst.numberId = number;
inst.sumOfBits = Long.bitCount(number);
if (romanNumeral != null) {
inst.romanNumeralSymbols = new ArrayList<>(romanNumeral.length());
for (int i = 0; i < romanNumeral.length(); i++)
inst.romanNumeralSymbols.add(romanNumeral.substring(i, i + 1));
}

return inst;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.openliberty.jpa.data.tests.models.Coordinate;
import io.openliberty.jpa.data.tests.models.NaturalNumber;
import io.openliberty.jpa.data.tests.models.Person;
import io.openliberty.jpa.data.tests.models.Prime;
import io.openliberty.jpa.data.tests.models.Rebate;
import io.openliberty.jpa.data.tests.models.Rebate.Status;
import jakarta.annotation.Resource;
Expand Down Expand Up @@ -338,4 +339,47 @@ public void testOLGH28931() throws Exception {
assertEquals(55901, result.location.address.zip);
}

@Test
@Ignore("Reference issue: https://github.com/OpenLiberty/open-liberty/issues/28925")
public void testOLGH28925() throws Exception {
Prime two = Prime.of(2, "II", "two");
Prime three = Prime.of(3, "III", "three");
Prime five = Prime.of(5, "V", "five");
Prime seven = Prime.of(7, "VII", "seven");

List<Prime> primes;

tx.begin();
em.persist(two);
em.persist(three);
em.persist(five);
em.persist(seven);
tx.commit();

tx.begin();
try {
primes = em.createQuery("SELECT ID(THIS) FROM Prime o WHERE (o.name = :numberName OR :numeral=o.romanNumeral OR o.hex =:hex OR ID(THIS)=:num) ORDER BY o.numberId",
Prime.class)
.setParameter("numberName", "two")
.setParameter("numeral", "III")
.setParameter("hex", "5")
.setParameter("num", 7)
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();

/*
* Recreate
* Exception Description: Problem compiling [SELECT ID(THIS) FROM Prime o WHERE (o.name = :numberName OR :numeral=o.romanNumeral OR o.hex =:hex OR ID(THIS)=:num) ORDER
* BY o.numberId].
* [10, 14] The identification variable 'THIS' is not defined in the FROM clause.
* [108, 112] The identification variable 'THIS' is not defined in the FROM clause.
*/
throw e;
}

assertEquals(4, primes.size());
}

}

0 comments on commit aaa483c

Please sign in to comment.