From 4febfe4d82f34a5d71bb1cbbd26f02afc72dc1a5 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 1 Jul 2011 13:45:05 -0700 Subject: [PATCH] HHH-6365 : Use Identifier.toIdentifier() to create column names --- .../java/org/hibernate/metamodel/relational/Column.java | 8 ++++++-- .../metamodel/relational/TableManipulationTests.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Column.java b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Column.java index 80c08d2b01..c41ad2366a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Column.java @@ -32,7 +32,7 @@ import org.hibernate.metamodel.relational.state.ColumnRelationalState; * @author Steve Ebersole */ public class Column extends AbstractSimpleValue implements SimpleValue { - private final String name; + private final Identifier name; private boolean nullable; private boolean unique; @@ -48,6 +48,10 @@ public class Column extends AbstractSimpleValue implements SimpleValue { private Size size = new Size(); protected Column(TableSpecification table, int position, String name) { + this( table, position, Identifier.toIdentifier( name ) ); + } + + protected Column(TableSpecification table, int position, Identifier name) { super( table, position ); this.name = name; } @@ -72,7 +76,7 @@ public class Column extends AbstractSimpleValue implements SimpleValue { } } - public String getName() { + public Identifier getName() { return name; } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/relational/TableManipulationTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/relational/TableManipulationTests.java index 6e453ad5c5..a5d436f0d8 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/relational/TableManipulationTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/relational/TableManipulationTests.java @@ -67,7 +67,7 @@ public class TableManipulationTests extends BaseUnitTestCase { for ( Value value : table.values() ) { assertTrue( Column.class.isInstance( value ) ); Column column = ( Column ) value; - if ( column.getName().equals( "id" ) ) { + if ( column.getName().equals( Identifier.toIdentifier( "id" ) ) ) { assertEquals( INTEGER, column.getDatatype() ); assertEquals( 18, column.getSize().getPrecision() ); assertEquals( 0, column.getSize().getScale() ); @@ -75,7 +75,7 @@ public class TableManipulationTests extends BaseUnitTestCase { assertNull( column.getSize().getLobMultiplier() ); } else { - assertEquals( "col_1", column.getName() ); + assertEquals( Identifier.toIdentifier( "col_1" ), column.getName() ); assertEquals( VARCHAR, column.getDatatype() ); assertEquals( -1, column.getSize().getPrecision() ); assertEquals( -1, column.getSize().getScale() );