Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/io.openliberty.data.internal_fat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
apply from: '../wlp-gradle/subprojects/maven-central-mirror.gradle'

ext {
hibernateVersion = '7.0.9.Final'
hibernateVersion = '7.1.9.Final'
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class DataTestServlet extends FATServlet {
@Inject
Apartments apartments;

@Inject
ApartmentsSpecific apartmentsSpecific;

@Inject
EmptyRepository emptyRepo;

Expand Down Expand Up @@ -662,28 +665,20 @@ public void testConvertLongValue() throws Exception {
.floatValue(),
0.01f);

if (skipForHibernate("https://github.com/OpenLiberty/open-liberty/issues/33182")) {
//TODO remove skip when fixed in Hibernate
} else {
assertEquals(31,
primes.numberAsInt(31));
assertEquals(31,
primes.numberAsInt(31));

assertEquals(29,
primes.numberAsInteger(29L).orElseThrow().intValue());
}
assertEquals(29,
primes.numberAsInteger(29L).orElseThrow().intValue());

assertEquals(23L,
primes.numberAsLong(23));

assertEquals(19L,
primes.numberAsLongWrapper(19).orElseThrow().longValue());

if (skipForHibernate("https://github.com/OpenLiberty/open-liberty/issues/33182")) {
//TODO remove skip when fixed in Hibernate
} else {
assertEquals((short) 4013,
primes.numberAsShort(4013));
}
assertEquals((short) 4013,
primes.numberAsShort(4013));

assertEquals((short) 4007,
primes.numberAsShortWrapper(4007).orElseThrow().shortValue());
Expand Down Expand Up @@ -1123,6 +1118,10 @@ public void testDefaultRepositoryMethod() {
*/
@Test
public void testDeleteIgnoresFirstKeywork() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

packages.deleteAll(); //cleanup before test

packages.save(new Package(10001, 10.0f, 13.0f, 4.0f, "testDeleteIgnoresFirstKeywork#10001"));
Expand All @@ -1144,6 +1143,10 @@ public void testDeleteIgnoresFirstKeywork() {
*/
@Test
public void testDeleteQueryByParameters() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

houses.dropAll();

House h1 = new House();
Expand Down Expand Up @@ -1719,6 +1722,10 @@ public void testExistsAsync() throws ExecutionException, //
*/
@Test
public void testFindAndDelete() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

packages.save(new Package(40001, 41.0f, 14.0f, 4.0f, "testFindAndDelete#40001"));
packages.save(new Package(40004, 44.0f, 40.4f, 4.4f, "testFindAndDelete#40004"));
packages.save(new Package(40012, 42.0f, 12.0f, 2.0f, "testFindAndDelete#4001x"));
Expand Down Expand Up @@ -1779,6 +1786,10 @@ public void testFindAndDelete() {
*/
@Test
public void testFindAndDeleteAnnotated() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

packages.save(new Package(50001, 51.0f, 31.0f, 21.0f, "testFindAndDeleteAnnotated#50001"));
packages.save(new Package(50002, 52.0f, 32.0f, 22.0f, "testFindAndDeleteAnnotated#50002"));

Expand Down Expand Up @@ -1809,6 +1820,10 @@ public void testFindAndDeleteAnnotated() {
*/
@Test
public void testFindAndDeleteMultipleAnnotated() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

packages.save(new Package(60001, 61.0f, 41.0f, 26.0f, "testFindAndDeleteMultipleAnnotated"));
packages.save(new Package(60002, 62.0f, 42.0f, 25.0f, "testFindAndDeleteMultipleAnnotated"));
packages.save(new Package(60003, 59.0f, 39.0f, 24.0f, "testFindAndDeleteMultipleAnnotated"));
Expand Down Expand Up @@ -1859,6 +1874,10 @@ public void testFindAndDeleteReturnsIds() throws Exception {
String jdbcJarName = System.getenv().getOrDefault("DB_DRIVER", "UNKNOWN");
boolean supportsOrderByForUpdate = !jdbcJarName.startsWith("derby");

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

packages.deleteAll();

packages.save(new Package(80081, 18.0f, 18.1f, 8.8f, "testFindAndDeleteReturnsIds#80081"));
Expand Down Expand Up @@ -1899,6 +1918,10 @@ public void testFindAndDeleteReturnsObjects() {
String jdbcJarName = System.getenv().getOrDefault("DB_DRIVER", "UNKNOWN");
boolean supportsOrderByForUpdate = !jdbcJarName.startsWith("derby");

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

packages.deleteAll();

// id length width height description
Expand Down Expand Up @@ -2250,11 +2273,7 @@ public void testFromClauseIdentifiesEntity() {
prod3.price = 16.99f;
prod3 = multi.create(prod3);

if (skipForHibernate("https://github.com/OpenLiberty/open-liberty/issues/33182")) {
//TODO remove skip when fixed in Hibernate or Liberty
} else {
assertEquals(3L, multi.countEverything());
}
assertEquals(3L, multi.countEverything());

assertEquals(1L, multi.discount("TestFromClauseIdentifiesEntity-Product-3", 0.30f));
assertEquals(3L, multi.discount("TestFromClauseIdentifiesEntity-Product-_", 0.20f));
Expand All @@ -2265,11 +2284,8 @@ public void testFromClauseIdentifiesEntity() {

assertEquals(3L, multi.destroy("TestFromClauseIdentifiesEntity-%"));

if (skipForHibernate("https://github.com/OpenLiberty/open-liberty/issues/33182")) {
//TODO remove skip when fixed in Hibernate or Liberty
} else {
assertEquals(0L, multi.countEverything());
}
assertEquals(0L, multi.countEverything());

}

/**
Expand Down Expand Up @@ -3835,9 +3851,26 @@ public void testMultipleEntitiesInARepository() {

assertEquals(true, multi.remove(added.get(2)));

assertEquals(true, multi.deleteById(908070605l).isPresent());
assertEquals(true, multi.deleteById(807060504l).isPresent());
assertEquals(false, multi.deleteById(706050403l).isPresent());
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
// TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
assertEquals(true, multi.remove(p1));
assertEquals(true, multi.remove(p2));
try {
assertEquals(false, multi.remove(p3));
} catch (OptimisticLockingFailureException e) {
//TODO we currently throw an exception when trying to delete an entity that does not exist.
// however, shouldn't we just return false?
}
} else {
assertEquals(true, multi.deleteById(908070605l).isPresent());
assertEquals(true, multi.deleteById(807060504l).isPresent());
assertEquals(false, multi.deleteById(706050403l).isPresent());
}

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
packages.deleteAll();
return; // TODO remove once fixed in Hibernate - Cannot modify with pessimistic lock
}

prod.name = "Test-Multiple-Entities-In-A-Repository-Product";
assertEquals(1, multi.modify(prod));
Expand Down Expand Up @@ -4085,7 +4118,11 @@ public void testParameterAnnotationTakesPrecedenceOverMethodPrefix() {
*/
@Test
public void testPersistentFieldNamesAndDelimiters() {
apartments.removeAll();
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
apartmentsSpecific.removeAll(); // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
} else {
apartments.removeAll();
}

Apartment a101 = new Apartment();
a101.occupant = new Occupant();
Expand Down Expand Up @@ -5999,6 +6036,10 @@ public void testUpdateWithEntityParameter() {
*/
@Test
public void testUpdateWithVersionedEntityParameter() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot update with pessimistic lock
}

Product prod1 = new Product();
prod1.pk = UUID.nameUUIDFromBytes("UPD-VER-EP-1".getBytes());
prod1.name = "testUpdateWithVersionedEntityParameter Product 1";
Expand Down
2 changes: 1 addition & 1 deletion dev/io.openliberty.data.internal_fat_jpa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
apply from: '../wlp-gradle/subprojects/maven-central-mirror.gradle'

ext {
hibernateVersion = '7.0.9.Final'
hibernateVersion = '7.1.9.Final'
}

configurations {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Optional<CityId> deleteAtMost1ByStateName(String state,

LinkedList<CityId> deleteByStateName(String state);

// TODO remove once https://github.com/OpenLiberty/open-liberty/issues/33535 is resolved
void deleteVoidByStateName(String state);

Iterable<CityId> deleteByStateName(String state, Limit limit, Order<City> sorts);

@Delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,26 @@ public static boolean skipForHibernate(String... issues) {
return isHibernate();
}

/**
* Temporary method to allow skipping tests for tests that
* fail due to incompatibilities between our Jakarta Data provider
* and Hibernate's Jakarta Persistence provider on a specific database.
*
* @param driver - driver name prefix (i.e. derby)
* @param issues - the issues that describe why the test must be skipped on Hibernate
* @return boolean - true if we need to skip the test, false otherwise.
*/
public static boolean skipForHibernateByDatabase(String driver, String... issues) {
boolean isHibernateAndDatabase = isHibernate() && System.getenv("DB_DRIVER").contains(driver);

if (isHibernateAndDatabase) {
System.out.println("Skipping test because database is " + System.getenv("DB_DRIVER") + " and " + Arrays.asList(issues));
}

return isHibernateAndDatabase;

}

@Override
public void init(ServletConfig config) throws ServletException {
// Some read-only data that is prepopulated for tests:
Expand Down Expand Up @@ -1169,6 +1189,10 @@ public void testFindAndDeleteEntityThatHasAnIdClass() {
String jdbcJarName = System.getenv().getOrDefault("DB_DRIVER", "UNKNOWN");
boolean supportsOrderByForUpdate = !jdbcJarName.startsWith("derby");

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

cities.save(new City("Milwaukee", "Wisconsin", 577222, Set.of(414)));
cities.save(new City("Green Bay", "Wisconsin", 107395, Set.of(920)));
cities.save(new City("Superior", "Wisconsin", 26751, Set.of(534, 715)));
Expand Down Expand Up @@ -1292,7 +1316,9 @@ public void testFindAndDeleteEntityThatHasAnIdClass() {
*/
@Test
public void testFindAndDeleteReturningIdClassList(HttpServletRequest request, HttpServletResponse response) {

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}
cities.save(new City("Davenport", "Iowa", 101724, Set.of(563)));
cities.save(new City("Sioux City", "Iowa", 85797, Set.of(712)));
cities.save(new City("Iowa City", "Iowa", 74828, Set.of(319)));
Expand Down Expand Up @@ -2402,7 +2428,9 @@ public void testFetchType() {
*/
@Test
public void testFindAndDeleteInTransaction() throws Exception {

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}
cities.save(new City("Grand Forks", "North Dakota", 59845, Set.of(701)));
cities.save(new City("Bismarck", "North Dakota", 77772, Set.of(701)));
cities.save(new City("Fargo", "North Dakota", 136285, Set.of(701)));
Expand Down Expand Up @@ -3760,6 +3788,9 @@ public void testMixedRepository() {
*/
@Test
public void testMultipleThreadsVersionedUpdate() throws Exception {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot update with pessimistic lock
}
orders.deleteAll();

PurchaseOrder o = new PurchaseOrder();
Expand Down Expand Up @@ -3858,6 +3889,9 @@ else if (c.number == 5000921052220002L)
*/
@Test
public void testOneToOne() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}

drivers.deleteByFullNameEndsWith(" TestOneToOne");

Expand Down Expand Up @@ -4161,7 +4195,11 @@ public void testParenthesisInsertionForCursorPagination() {
*/
@Test
public void testSaveInTransaction() throws Exception {
cities.deleteByStateName("Montana");
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
cities.deleteVoidByStateName("Montana");; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
} else {
cities.deleteByStateName("Montana");
}

tran.begin();
try {
Expand All @@ -4186,7 +4224,11 @@ public void testSaveInTransaction() throws Exception {
assertEquals(117116, city.population);
assertEquals(Set.of(406), city.areaCodes);

cities.deleteByStateName("Montana");
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
cities.deleteVoidByStateName("Montana");; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
} else {
cities.deleteByStateName("Montana");
}
}

/**
Expand Down Expand Up @@ -4769,15 +4811,16 @@ public void testUpdateEntityWithIdClass() {
*/
@Test
public void testUpdateEntityWithIdClassAndVersion() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot update with pessimistic lock
}

CityId mnId = CityId.of("Rochester", "Minnesota");
CityId nyId = CityId.of("Rochester", "New York");

long mnVer;
long nyVer;
if (skipForHibernate("https://github.com/OpenLiberty/open-liberty/issues/33182")) {
// TODO once fixed in Hibernate, update the JPQL query to use VERSION(THIS)
// instead of lower case VERSION(this)
if (isHibernate()) {
mnVer = cities.currentVersion(mnId);
nyVer = cities.currentVersion(nyId);
} else {
Expand Down Expand Up @@ -4822,7 +4865,9 @@ public void testUpdateEntityWithIdClassAndVersion() {
*/
@Test
public void testUpdateInTransaction() throws Exception {

if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot update with pessimistic lock
}
Mobile m1 = mobilePhones.insert(Mobile.of(OS.ANDROID,
List.of("settings",
"messages",
Expand Down Expand Up @@ -5111,6 +5156,9 @@ public void testUpdateWithEntityResults() {
*/
@Test
public void testVersionedDelete() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot delete with pessimistic lock
}
orders.deleteAll();

PurchaseOrder o1 = new PurchaseOrder();
Expand Down Expand Up @@ -5230,6 +5278,9 @@ public void testVersionedRemoval() {
*/
@Test
public void testVersionedUpdate() {
if (skipForHibernateByDatabase("derby", "https://github.com/OpenLiberty/open-liberty/issues/33535")) {
return; // TODO remove once fixed in Hibernate - Cannot update with pessimistic lock
}
orders.deleteAll();

PurchaseOrder o1 = new PurchaseOrder();
Expand Down