diff --git a/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/AdvancedTableCreator.java b/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/AdvancedTableCreator.java index fc48a1a3e7..0572a2aa6a 100644 --- a/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/AdvancedTableCreator.java +++ b/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/AdvancedTableCreator.java @@ -131,7 +131,7 @@ public AdvancedTableCreator() { addTableDefinition(buildPlanarbeitsgangTable()); addTableDefinition(buildPlanarbeitsgangHistTable()); addTableDefinition(buildMaterialReignisTable()); - addTableDefinition(EntityFloat.Populator.buildTable()); + addTableDefinition(buildEntityFloatTable()); } public TableDefinition buildADDRESSTable() { @@ -3652,6 +3652,18 @@ public TableDefinition buildMaterialReignisTable() { return tabledefinition; } + // Supported data types according to https://docs.oracle.com/cd/E19501-01/819-3659/gcmaz/ + private static TableDefinition buildEntityFloatTable() { + TableDefinition table = new TableDefinition(); + table.setName(EntityFloat.TABLE_NAME); + table.addField(createNumericPk("ID", 10)); + table.addField(createFloatColumn("HEIGHT", false)); + table.addField(createFloatColumn("LENGTH", false)); + table.addField(createFloatColumn("WIDTH", false)); + table.addField(createStringColumn("DESCRIPTION", 255,false)); + return table; + } + @Override public void replaceTables(DatabaseSession session) { DatabasePlatform dbPlatform = session.getPlatform(); diff --git a/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/entities/EntityFloat.java b/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/entities/EntityFloat.java index be4d446abe..6409f4629e 100644 --- a/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/entities/EntityFloat.java +++ b/jpa/eclipselink.jpa.testapps/jpa.test.advanced/src/main/java/org/eclipse/persistence/testing/models/jpa/advanced/entities/EntityFloat.java @@ -12,24 +12,17 @@ */ package org.eclipse.persistence.testing.models.jpa.advanced.entities; -import java.util.Arrays; -import java.util.List; - import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; -import org.eclipse.persistence.sessions.Session; -import org.eclipse.persistence.sessions.UnitOfWork; -import org.eclipse.persistence.testing.framework.TogglingFastTableCreator; -import org.eclipse.persistence.tools.schemaframework.TableDefinition; // Based on reproduction scenario from issue #2301 (https://github.com/eclipse-ee4j/eclipselink/issues/2301) @Entity @Table(name = EntityFloat.TABLE_NAME) public class EntityFloat { - static final String TABLE_NAME = "ADV_ENTITY_FLOAT"; + public static final String TABLE_NAME = "ADV_ENTITY_FLOAT"; @Id @Column(name = "ID") @@ -106,41 +99,4 @@ public String toString() { id, length, width, height, description); } - // Based on reproduction scenario from issue #2301 (https://github.com/eclipse-ee4j/eclipselink/issues/2301) - public static final class Populator extends TogglingFastTableCreator { - - public static EntityFloat[] ENTITY_FLOAT = new EntityFloat[] { - // Tallest and smallest length - new EntityFloat(70071, 17.0f, 17.1f, 7.7f, "testOLGH28289#70071"), - // Tallest and largest length - new EntityFloat(70077, 77.0f, 17.7f, 7.7f, "testOLGH28289#70077"), - new EntityFloat(70007, 70.0f, 10.7f, 0.7f, "testOLGH28289#70007") - }; - - public static void populate(Session session) { - List entities = Arrays.asList(ENTITY_FLOAT); - UnitOfWork unitOfWork = session.acquireUnitOfWork(); - unitOfWork.removeAllReadOnlyClasses(); - unitOfWork.registerAllObjects(entities); - unitOfWork.commit(); - } - - // Supported data types according to https://docs.oracle.com/cd/E19501-01/819-3659/gcmaz/ - public static TableDefinition buildTable() { - TableDefinition table = new TableDefinition(); - table.setName(TABLE_NAME); - table.addField(createNumericPk("ID", 10)); - table.addField(createFloatColumn("HEIGHT", false)); - table.addField(createFloatColumn("LENGTH", false)); - table.addField(createFloatColumn("WIDTH", false)); - table.addField(createStringColumn("DESCRIPTION", 255,false)); - return table; - } - - private Populator() { - throw new UnsupportedOperationException("No instances of EntityFloatPopulator are allowed"); - } - - } - } diff --git a/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/AdvancedQueryTest.java b/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/AdvancedQueryTest.java index 25469ff658..58cb9dbb84 100644 --- a/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/AdvancedQueryTest.java +++ b/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/AdvancedQueryTest.java @@ -187,7 +187,7 @@ public void testSetup() { //Persist the examples in the database employeePopulator.persistExample(session); // EntityFloat instances to test issue #2301 - EntityFloat.Populator.populate(session); + EntityFloatPopulator.populate(session); } public void testTearDown() { diff --git a/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/EntityFloatPopulator.java b/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/EntityFloatPopulator.java new file mode 100644 index 0000000000..6a5fce1a8d --- /dev/null +++ b/jpa/eclipselink.jpa.testapps/jpa.test.jpql/src/test/java/org/eclipse/persistence/testing/tests/jpa/jpql/advanced/EntityFloatPopulator.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024 IBM Corporation. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +package org.eclipse.persistence.testing.tests.jpa.jpql.advanced; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.persistence.sessions.Session; +import org.eclipse.persistence.sessions.UnitOfWork; +import org.eclipse.persistence.testing.models.jpa.advanced.entities.EntityFloat; + +class EntityFloatPopulator { + + private EntityFloatPopulator() { + throw new UnsupportedOperationException("No instances of EntityFloatPopulator are allowed"); + } + + static EntityFloat[] ENTITY_FLOAT = new EntityFloat[] { + // Tallest and smallest length + new EntityFloat(70071, 17.0f, 17.1f, 7.7f, "testOLGH28289#70071"), + // Tallest and largest length + new EntityFloat(70077, 77.0f, 17.7f, 7.7f, "testOLGH28289#70077"), + new EntityFloat(70007, 70.0f, 10.7f, 0.7f, "testOLGH28289#70007") + }; + + static void populate(Session session) { + List entities = Arrays.asList(ENTITY_FLOAT); + UnitOfWork unitOfWork = session.acquireUnitOfWork(); + unitOfWork.removeAllReadOnlyClasses(); + unitOfWork.registerAllObjects(entities); + unitOfWork.commit(); + } + +}