Skip to content

Commit 54f9acd

Browse files
authored
Merge pull request #30179 from ajaypaul-ibm/29781
2 parents e74ea01 + 5ac6792 commit 54f9acd

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 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 java.time.Instant;
13+
import java.time.ZonedDateTime;
14+
import java.time.ZoneId;
15+
16+
import jakarta.persistence.Entity;
17+
import jakarta.persistence.Id;
18+
19+
@Entity
20+
public class Store {
21+
22+
@Id
23+
public long purchaseId;
24+
25+
public String customer;
26+
27+
public Instant time;
28+
29+
public static Store of(int year, int month, int day,String customer,long purchaseId) {
30+
Store inst = new Store();
31+
inst.purchaseId = purchaseId;
32+
inst.customer = customer;
33+
inst.time = ZonedDateTime.of(year, month, day, 12, 0, 0, 0, ZoneId.of("America/New_York")).toInstant();
34+
return inst;
35+
}
36+
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import io.openliberty.jpa.data.tests.models.Rebate.Status;
6969
import io.openliberty.jpa.data.tests.models.Reciept;
7070
import io.openliberty.jpa.data.tests.models.Segment;
71+
import io.openliberty.jpa.data.tests.models.Store;
7172
import io.openliberty.jpa.data.tests.models.Triangle;
7273
import jakarta.annotation.Resource;
7374
import jakarta.persistence.EntityManager;
@@ -1361,6 +1362,36 @@ public void testOLGH28898() throws Exception {
13611362
assertEquals(1, count);
13621363
}
13631364

1365+
@Test
1366+
//Reference issue : https://github.com/OpenLiberty/open-liberty/issues/29781
1367+
public void testOLGH29781() throws Exception {
1368+
ZoneId ET = ZoneId.of("America/New_York");
1369+
Instant when = ZonedDateTime.of(2022, 4, 29, 12, 0, 0, 0, ET)
1370+
.toInstant();
1371+
Store s1 = Store.of(2022, 4, 29, "Billy", 12L);
1372+
Store s2 = Store.of(2024, 5, 12, "Bobby", 9L);
1373+
1374+
int count;
1375+
1376+
tx.begin();
1377+
em.persist(s1);
1378+
em.persist(s2);
1379+
tx.commit();
1380+
1381+
tx.begin();
1382+
try {
1383+
count = em.createQuery("DELETE FROM Store WHERE this.time>:when")
1384+
.setParameter("when", when)
1385+
.executeUpdate();
1386+
tx.commit();
1387+
} catch (Exception e) {
1388+
tx.rollback();
1389+
throw e;
1390+
}
1391+
1392+
assertEquals(1, count);
1393+
}
1394+
13641395
@Test
13651396
// Reference issue : https://github.com/OpenLiberty/open-liberty/issues/28895
13661397
public void testOLGH28895() throws Exception {

0 commit comments

Comments
 (0)