Merge remote-tracking branch 'upstream/master' into wip/6.0
This commit is contained in:
commit
b89658628e
|
@ -1130,9 +1130,6 @@ public class ActionQueue {
|
|||
}
|
||||
}
|
||||
|
||||
// the mapping of entity names to their latest batch numbers.
|
||||
private List<BatchIdentifier> latestBatches;
|
||||
|
||||
// the map of batch numbers to EntityInsertAction lists
|
||||
private Map<BatchIdentifier, List<AbstractEntityInsertAction>> actionBatches;
|
||||
|
||||
|
@ -1144,9 +1141,11 @@ public class ActionQueue {
|
|||
*/
|
||||
public void sort(List<AbstractEntityInsertAction> insertions) {
|
||||
// optimize the hash size to eliminate a rehash.
|
||||
this.latestBatches = new ArrayList<>( );
|
||||
this.actionBatches = new HashMap<>();
|
||||
|
||||
// the mapping of entity names to their latest batch numbers.
|
||||
final List<BatchIdentifier> latestBatches = new ArrayList<>();
|
||||
|
||||
for ( AbstractEntityInsertAction action : insertions ) {
|
||||
BatchIdentifier batchIdentifier = new BatchIdentifier(
|
||||
action.getEntityName(),
|
||||
|
@ -1157,8 +1156,6 @@ public class ActionQueue {
|
|||
.getRootEntityName()
|
||||
);
|
||||
|
||||
// the entity associated with the current action.
|
||||
Object currentEntity = action.getInstance();
|
||||
int index = latestBatches.indexOf( batchIdentifier );
|
||||
|
||||
if ( index != -1 ) {
|
||||
|
@ -1268,8 +1265,8 @@ public class ActionQueue {
|
|||
|
||||
for ( int i = 0; i < propertyValues.length; i++ ) {
|
||||
Object value = propertyValues[i];
|
||||
Type type = propertyTypes[i];
|
||||
if ( value != null ) {
|
||||
Type type = propertyTypes[i];
|
||||
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.tool.schema.scripts;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-14249")
|
||||
public class MultiLineImportWithSpacesAfterTheLastStatementTest {
|
||||
public static final String IMPORT_FILE = "org/hibernate/orm/test/tool/schema/scripts/multi-line-statements-with-spaces-after-last-delimiter.sql";
|
||||
|
||||
private final MultipleLinesSqlCommandExtractor extractor = new MultipleLinesSqlCommandExtractor();
|
||||
|
||||
@Test
|
||||
public void testExtraction() throws Exception {
|
||||
final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||
|
||||
try (final InputStream stream = classLoader.getResourceAsStream( IMPORT_FILE )) {
|
||||
assertThat( stream, notNullValue() );
|
||||
try (final InputStreamReader reader = new InputStreamReader( stream )) {
|
||||
final List<String> commands = extractor.extractCommands( reader, Dialect.getDialect() );
|
||||
assertThat( commands, notNullValue() );
|
||||
assertThat( commands.size(), is( 3 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.tool.schema.scripts;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-14249")
|
||||
public class MultiLineImportWithTabsAndSpacesTest {
|
||||
public static final String IMPORT_FILE = "org/hibernate/orm/test/tool/schema/scripts/multi-line-statements-starting-with-tabs-and-spaces.sql";
|
||||
|
||||
private final MultipleLinesSqlCommandExtractor extractor = new MultipleLinesSqlCommandExtractor();
|
||||
|
||||
@Test
|
||||
public void testExtraction() throws Exception {
|
||||
final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||
|
||||
try (final InputStream stream = classLoader.getResourceAsStream( IMPORT_FILE )) {
|
||||
assertThat( stream, notNullValue() );
|
||||
try (final InputStreamReader reader = new InputStreamReader( stream )) {
|
||||
final List<String> commands = extractor.extractCommands( reader, Dialect.getDialect() );
|
||||
assertThat( commands, notNullValue() );
|
||||
assertThat( commands.size(), is( 3 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
CREATE TABLE test_data (
|
||||
id NUMBER NOT NULL PRIMARY KEY -- primary key
|
||||
, text VARCHAR2(100) /* any other data */
|
||||
); DELETE
|
||||
FROM test_data;
|
||||
|
||||
INSERT INTO test_data VALUES (1, 'sample');
|
|
@ -0,0 +1,7 @@
|
|||
CREATE TABLE test_data (
|
||||
id NUMBER NOT NULL PRIMARY KEY -- primary key
|
||||
, text VARCHAR2(100) /* any other data */
|
||||
); DELETE
|
||||
FROM test_data;
|
||||
|
||||
INSERT INTO test_data VALUES (1, 'sample');
|
Loading…
Reference in New Issue