Skip to content

Commit

Permalink
Issue #2301 - Review notes applied.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <[email protected]>
  • Loading branch information
Tomas-Kraus committed Dec 4, 2024
1 parent 614c8c2 commit 7e693fd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public AdvancedTableCreator() {
addTableDefinition(buildPlanarbeitsgangTable());
addTableDefinition(buildPlanarbeitsgangHistTable());
addTableDefinition(buildMaterialReignisTable());
addTableDefinition(EntityFloat.Populator.buildTable());
addTableDefinition(buildEntityFloatTable());
}

public TableDefinition buildADDRESSTable() {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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<Object> 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");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Object> entities = Arrays.asList(ENTITY_FLOAT);
UnitOfWork unitOfWork = session.acquireUnitOfWork();
unitOfWork.removeAllReadOnlyClasses();
unitOfWork.registerAllObjects(entities);
unitOfWork.commit();
}

}

0 comments on commit 7e693fd

Please sign in to comment.