Permalink
Browse files

Revert "HHH-7612 - Fix and test"

This reverts commit 14d1c62.
  • Loading branch information...
1 parent caf2ee4 commit 5707798b4b4a3a7b99fc47faf5575ec11be2c4e0 @stliu stliu committed Nov 28, 2012
@@ -29,7 +29,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -458,7 +457,7 @@ public String sqlTemporaryTableCreateString(Dialect dialect, Mapping mapping) th
.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 +491,7 @@ public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog,
pkname = ( (Column) getPrimaryKey().getColumnIterator().next() ).getQuotedName( dialect );
}
- Iterator iter = getSortedColumnIterator();
+ Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
Column col = (Column) iter.next();
@@ -592,33 +591,6 @@ public String sqlCreateString(Dialect dialect, Mapping p, String defaultCatalog,
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<Column> getSortedColumnIterator() {
- final LinkedHashSet<Column> sortedColumns = new LinkedHashSet<Column>();
- // 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() ) {
@@ -34,8 +34,8 @@ public void testGeneratedSql() {
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());
@@ -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');
+INSERT INTO `vgras029_v031` VALUES (1,'Foo Foo Foo',1), (1,'Bar Bar Bar',2);
@@ -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
- );
- }
-}

0 comments on commit 5707798

Please sign in to comment.