Skip to content

Commit d9d948c

Browse files
Merge pull request #32567 from pardhiv-krishna/32246_Recreate
Recreate OpenLiberty Issue #32246
2 parents 036262a + c787da9 commit d9d948c

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*******************************************************************************/
10+
package io.openliberty.jpa.data.tests.models;
11+
12+
import jakarta.persistence.Entity;
13+
import jakarta.persistence.Id;
14+
15+
/**
16+
* JPA entity representing a student.
17+
* Contains a roll number, name, and an array of marks.
18+
*/
19+
@Entity
20+
public class Student {
21+
22+
@Id
23+
public long rollNo;
24+
25+
public String name;
26+
27+
public int[] marks;
28+
29+
public Student() {
30+
}
31+
32+
public Student(long rollNo, String name, int[] marks) {
33+
this.rollNo = rollNo;
34+
this.name = name;
35+
this.marks = marks;
36+
}
37+
}

dev/com.ibm.ws.jpa.tests.jpa_32_fat/test-applications/jakartadata/src/io/openliberty/jpa/data/tests/web/JakartaDataRecreateServlet.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import io.openliberty.jpa.data.tests.models.ShippingAddress;
7979
import io.openliberty.jpa.data.tests.models.Store;
8080
import io.openliberty.jpa.data.tests.models.StreetAddress;
81+
import io.openliberty.jpa.data.tests.models.Student;
8182
import io.openliberty.jpa.data.tests.models.TaxPayer;
8283
import io.openliberty.jpa.data.tests.models.Triangle;
8384
import io.openliberty.jpa.data.tests.models.Vehicle;
@@ -2431,6 +2432,38 @@ public void testOLGH32204() throws Exception {
24312432
assertEquals(40000f, result.get(0).income, 0.01);
24322433
assertEquals(60000f, result.get(1).income, 0.01);
24332434
}
2435+
2436+
@Test
2437+
// Reference issue: https://github.com/OpenLiberty/open-liberty/issues/32246
2438+
public void testOLGH32246() throws Exception {
2439+
deleteAllEntities(Student.class);
2440+
2441+
Student s1 = new Student(1L, "Achu", new int[] { 90, 85, 88 });
2442+
Student s2 = new Student(2L, "Appu", new int[] { 75, 80, 70 });
2443+
Student s3 = new Student(3L, "Ammu", new int[] { 70, 90, 75 });
2444+
2445+
tx.begin();
2446+
em.persist(s1);
2447+
em.persist(s2);
2448+
em.persist(s3);
2449+
tx.commit();
2450+
2451+
List<?> resultStudents;
2452+
try {
2453+
resultStudents = em.createQuery("SELECT s.marks FROM Student s WHERE s.rollNo = ?1", Student.class) // Forcing ConversionException by giving wrong entity class
2454+
.setParameter(1, 3L)
2455+
.getResultList();
2456+
} catch (Exception e) {
2457+
throw e;
2458+
}
2459+
2460+
assertEquals(
2461+
List.of(Arrays.toString(new int[] { 70, 90, 75 })),
2462+
resultStudents.stream()
2463+
.map(o -> Arrays.toString((int[]) o))
2464+
.collect(Collectors.toList()));
2465+
2466+
}
24342467

24352468
/**
24362469
* Utility method to drop all entities from table.

0 commit comments

Comments
 (0)