Skip to content

Commit

Permalink
Issue eclipse-ee4j#2339 - junit test
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <[email protected]>
  • Loading branch information
Tomas-Kraus committed Feb 7, 2025
1 parent 473882b commit c0980c7
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2734,4 +2734,42 @@ public void testFloatSortWithPessimisticLock() {
assertEquals(70077, entities.get(1).getId());
}

// Based on reproduction scenario from issue #2339
public void testFloatQualifiedIdProjectionWithPessimisticLock() {
EntityManager em = createEntityManager();
beginTransaction(em);
List<Integer> results;
try {
results = em.createQuery("SELECT f.id FROM EntityFloat f ORDER BY f.width DESC", Integer.class)
.setLockMode(LockModeType.PESSIMISTIC_WRITE)
.setMaxResults(1)
.getResultList();
commitTransaction(em);
} catch (PersistenceException ex) {
rollbackTransaction(em);
throw ex;
}
assertEquals(1, results.size());
assertEquals(70077, results.get(0).intValue());
}

// Based on reproduction scenario from issue #2339
public void testFloatSimpleIdProjectionWithPessimisticLock() {
EntityManager em = createEntityManager();
beginTransaction(em);
List<Integer> results;
try {
results = em.createQuery("SELECT id FROM EntityFloat ORDER BY width DESC", Integer.class)
.setLockMode(LockModeType.PESSIMISTIC_WRITE)
.setMaxResults(1)
.getResultList();
commitTransaction(em);
} catch (PersistenceException ex) {
rollbackTransaction(em);
throw ex;
}
assertEquals(1, results.size());
assertEquals(70077, results.get(0).intValue());
}

}

0 comments on commit c0980c7

Please sign in to comment.