diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java index e3825b0c6c..ec03deb301 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java @@ -458,7 +458,7 @@ public class Table implements RelationalModel, Serializable { .append( ' ' ) .append( name ) .append( " (" ); - Iterator itr = getSortedColumnIterator(); + Iterator itr = getColumnIterator(); while ( itr.hasNext() ) { final Column column = (Column) itr.next(); buffer.append( column.getQuotedName( dialect ) ).append( ' ' ); @@ -492,7 +492,7 @@ public class Table implements RelationalModel, Serializable { pkname = ( (Column) getPrimaryKey().getColumnIterator().next() ).getQuotedName( dialect ); } - Iterator iter = getSortedColumnIterator(); + Iterator iter = getColumnIterator(); while ( iter.hasNext() ) { Column col = (Column) iter.next(); @@ -592,33 +592,6 @@ public class Table implements RelationalModel, Serializable { return buf.append( dialect.getTableTypeString() ).toString(); } - /** - * @return Sorted column list so that primary key appears first, followed by foreign keys and other properties. - * Within each group columns are not sorted in any way. - */ - private Iterator getSortedColumnIterator() { - final LinkedHashSet sortedColumns = new LinkedHashSet(); - // Adding primary key columns. - if ( hasPrimaryKey() ) { - sortedColumns.addAll( getPrimaryKey().getColumns() ); - } - // Adding foreign key columns. - Iterator iter = getForeignKeyIterator(); - while ( iter.hasNext() ) { - ForeignKey fk = (ForeignKey) iter.next(); - sortedColumns.addAll( fk.getColumns() ); - } - // Adding other columns. - iter = getColumnIterator(); - while ( iter.hasNext() ) { - final Column column = (Column) iter.next(); - if ( ! sortedColumns.contains( column ) ) { - sortedColumns.add( column ); - } - } - return sortedColumns.iterator(); - } - public String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema) { StringBuilder buf = new StringBuilder( "drop table " ); if ( dialect.supportsIfExistsBeforeTableName() ) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java index f5ee380e2d..27325d900b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java @@ -34,8 +34,8 @@ public class NullablePrimaryKeyTest { for (String s : schema) { log.debug(s); } - String expectedMappingTableSql = "create table personAddress (person_id numeric(19,0) not null, " + - "address_id numeric(19,0), primary key (person_id))"; + String expectedMappingTableSql = "create table personAddress (address_id numeric(19,0), " + + "person_id numeric(19,0) not null, primary key (person_id))"; Assert.assertEquals( "Wrong SQL", expectedMappingTableSql, schema[2] ); } catch (Exception e) { Assert.fail(e.getMessage()); diff --git a/hibernate-core/src/test/java/org/hibernate/test/propertyref/import.sql b/hibernate-core/src/test/java/org/hibernate/test/propertyref/import.sql index 19f76aa056..b9d3a08744 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/propertyref/import.sql +++ b/hibernate-core/src/test/java/org/hibernate/test/propertyref/import.sql @@ -1,3 +1,3 @@ INSERT INTO `vgras007_v031` VALUES ('ZZZ','00',1); -INSERT INTO `vgras029_v031` VALUES (1,1,'Foo Foo Foo'), (1,2,'Bar Bar Bar'); \ No newline at end of file +INSERT INTO `vgras029_v031` VALUES (1,'Foo Foo Foo',1), (1,'Bar Bar Bar',2); \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaGenerationTest.java deleted file mode 100644 index c8ea44ae66..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaGenerationTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.hibernate.test.schemaupdate; - -import org.junit.Assert; -import org.junit.Test; - -import org.hibernate.dialect.H2Dialect; -import org.hibernate.engine.spi.Mapping; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.test.onetomany.Node; -import org.hibernate.testing.RequiresDialect; -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -/** - * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) - */ -public class SchemaGenerationTest extends BaseCoreFunctionalTestCase { - @Override - protected String[] getMappings() { - return new String[] { "onetomany/Node.hbm.xml" }; - } - - @Test - @TestForIssue( jiraKey = "HHH-7612" ) - @RequiresDialect( H2Dialect.class ) - public void testSqlCreatePrimaryAndForeignKeyOrder() { - final Mapping mappings = configuration().buildMapping(); - final PersistentClass persistentClass = configuration().getClassMapping( Node.class.getName() ); - final String sqlCreate = persistentClass.getTable().sqlCreateString( getDialect(), mappings, null, null ); - Assert.assertEquals( - "PK and FK columns should appear first in CREATE TABLE statement.", - "create table Node (id integer not null, node_id integer, description varchar(255), idx integer, primary key (id))", - sqlCreate - ); - } -}