Skip to content

Commit

Permalink
Issue #2301 - Fixed table definitions for Double and Float types.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomáš Kraus <[email protected]>
  • Loading branch information
Tomas-Kraus committed Nov 26, 2024
1 parent 47f1543 commit cf8a09b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,40 @@ protected static FieldDefinition createNumericColumn(

/**
* Helper method to create {@link FieldDefinition} instance for numeric column
* with given name to store float or double type values.
* with given name to store float type values.
* @param name Column name.
* @param allowNull Allow {@code null} values for column.
* @return Initialized {@link FieldDefinition} instance.
*/
protected static FieldDefinition createFloatColumn(
final String name, final boolean allowNull) {
final FieldDefinition field = new FieldDefinition();
field.setName(name);
field.setType(Float.class);
field.setShouldAllowNull(allowNull);
field.setIsPrimaryKey(false);
field.setUnique(false);
field.setIsIdentity(false);
return field;
}

/**
* Helper method to create {@link FieldDefinition} instance for numeric column
* with given name to store double type values.
* @param name Column name.
* @param allowNull Allow {@code null} values for column.
* @return Initialized {@link FieldDefinition} instance.
*/
protected static FieldDefinition createDoubleColumn(
final String name, final boolean allowNull) {
return createNumericColumn(name, 19, 4, allowNull);
final FieldDefinition field = new FieldDefinition();
field.setName(name);
field.setType(Double.class);
field.setShouldAllowNull(allowNull);
field.setIsPrimaryKey(false);
field.setUnique(false);
field.setIsIdentity(false);
return field;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.eclipse.persistence.sessions.Session;
import org.eclipse.persistence.sessions.UnitOfWork;
import org.eclipse.persistence.testing.framework.TogglingFastTableCreator;
import org.eclipse.persistence.testing.models.jpa.advanced.Employee;
import org.eclipse.persistence.tools.schemaframework.PopulationManager;
import org.eclipse.persistence.tools.schemaframework.TableDefinition;

// Based on reproduction scenario from issue #2301 (https://github.com/eclipse-ee4j/eclipselink/issues/2301)
Expand Down Expand Up @@ -132,9 +130,9 @@ public static TableDefinition buildTable() {
TableDefinition table = new TableDefinition();
table.setName(TABLE_NAME);
table.addField(createNumericPk("ID", 10));
table.addField(createDoubleColumn("HEIGHT", false));
table.addField(createDoubleColumn("LENGTH", false));
table.addField(createDoubleColumn("WIDTH", false));
table.addField(createFloatColumn("HEIGHT", false));
table.addField(createFloatColumn("LENGTH", false));
table.addField(createFloatColumn("WIDTH", false));
table.addField(createStringColumn("DESCRIPTION", 255,false));
return table;
}
Expand Down

0 comments on commit cf8a09b

Please sign in to comment.