HHH-13591 Fixing formatting of previous patch

This commit is contained in:
Sanne Grinovero 2019-08-20 08:41:00 +01:00
parent 19ac013eeb
commit 4661efa468
21 changed files with 105 additions and 103 deletions

View File

@ -20,10 +20,10 @@ import org.hibernate.bytecode.enhance.internal.tracker.SimpleFieldTracker;
import org.hibernate.bytecode.enhance.spi.CollectionTracker; import org.hibernate.bytecode.enhance.spi.CollectionTracker;
import org.hibernate.bytecode.enhance.spi.EnhancerConstants; import org.hibernate.bytecode.enhance.spi.EnhancerConstants;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
import org.hibernate.engine.spi.ExtendedSelfDirtinessTracker;
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import org.hibernate.engine.spi.CompositeOwner; import org.hibernate.engine.spi.CompositeOwner;
import org.hibernate.engine.spi.CompositeTracker; import org.hibernate.engine.spi.CompositeTracker;
import org.hibernate.engine.spi.ExtendedSelfDirtinessTracker;
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import net.bytebuddy.asm.Advice; import net.bytebuddy.asm.Advice;
@ -358,9 +358,9 @@ class CodeTemplates {
static void enter(@FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) { static void enter(@FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) { if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
Object[] array = field.toArray(); Object[] array = field.toArray();
for (Object array1 : array) { for ( Object array1 : array ) {
if (argument == null || !argument.contains(array1)) { if ( argument == null || !argument.contains( array1 ) ) {
setterNull(array1, null); setterNull( array1, null );
} }
} }
} }
@ -370,9 +370,9 @@ class CodeTemplates {
static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) { static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) { if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
Object[] array = argument.toArray(); Object[] array = argument.toArray();
for (Object array1 : array) { for ( Object array1 : array ) {
if (Hibernate.isPropertyInitialized(array1, mappedBy) && getter(array1) != self) { if ( Hibernate.isPropertyInitialized( array1, mappedBy ) && getter( array1 ) != self ) {
setterSelf(array1, self); setterSelf( array1, self );
} }
} }
} }
@ -399,9 +399,9 @@ class CodeTemplates {
static void enter(@FieldValue Map<?, ?> field, @Advice.Argument(0) Map<?, ?> argument, @MappedBy String mappedBy) { static void enter(@FieldValue Map<?, ?> field, @Advice.Argument(0) Map<?, ?> argument, @MappedBy String mappedBy) {
if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) { if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
Object[] array = field.values().toArray(); Object[] array = field.values().toArray();
for (Object array1 : array) { for ( Object array1 : array ) {
if (argument == null || !argument.values().contains(array1)) { if ( argument == null || !argument.values().contains( array1 ) ) {
setterNull(array1, null); setterNull( array1, null );
} }
} }
} }
@ -411,9 +411,9 @@ class CodeTemplates {
static void exit(@Advice.This Object self, @Advice.Argument(0) Map<?, ?> argument, @MappedBy String mappedBy) { static void exit(@Advice.This Object self, @Advice.Argument(0) Map<?, ?> argument, @MappedBy String mappedBy) {
if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) { if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
Object[] array = argument.values().toArray(); Object[] array = argument.values().toArray();
for (Object array1 : array) { for ( Object array1 : array ) {
if (Hibernate.isPropertyInitialized(array1, mappedBy) && getter(array1) != self) { if ( Hibernate.isPropertyInitialized( array1, mappedBy ) && getter( array1 ) != self ) {
setterSelf(array1, self); setterSelf( array1, self );
} }
} }
} }
@ -467,9 +467,9 @@ class CodeTemplates {
static void enter(@Advice.This Object self, @FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) { static void enter(@Advice.This Object self, @FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) { if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
Object[] array = field.toArray(); Object[] array = field.toArray();
for (Object array1 : array) { for ( Object array1 : array ) {
if (argument == null || !argument.contains(array1)) { if ( argument == null || !argument.contains( array1 ) ) {
getter(array1).remove(self); getter( array1 ).remove( self );
} }
} }
} }
@ -479,9 +479,9 @@ class CodeTemplates {
static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) { static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) { if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
Object[] array = argument.toArray(); Object[] array = argument.toArray();
for (Object array1 : array) { for ( Object array1 : array ) {
if (Hibernate.isPropertyInitialized(array1, mappedBy)) { if ( Hibernate.isPropertyInitialized( array1, mappedBy ) ) {
Collection<Object> c = getter(array1); Collection<Object> c = getter( array1 );
if ( c != self && c != null ) { if ( c != self && c != null ) {
c.add( self ); c.add( self );
} }

View File

@ -1124,9 +1124,9 @@ public class BinderHelper {
public static Map<String,String> toAliasTableMap(SqlFragmentAlias[] aliases){ public static Map<String,String> toAliasTableMap(SqlFragmentAlias[] aliases){
Map<String,String> ret = new HashMap<>(); Map<String,String> ret = new HashMap<>();
for (SqlFragmentAlias aliase : aliases) { for ( SqlFragmentAlias aliase : aliases ) {
if (StringHelper.isNotEmpty(aliase.table())) { if ( StringHelper.isNotEmpty( aliase.table() ) ) {
ret.put(aliase.alias(), aliase.table()); ret.put( aliase.alias(), aliase.table() );
} }
} }
return ret; return ret;
@ -1134,9 +1134,9 @@ public class BinderHelper {
public static Map<String,String> toAliasEntityMap(SqlFragmentAlias[] aliases){ public static Map<String,String> toAliasEntityMap(SqlFragmentAlias[] aliases){
Map<String,String> ret = new HashMap<>(); Map<String,String> ret = new HashMap<>();
for (SqlFragmentAlias aliase : aliases) { for ( SqlFragmentAlias aliase : aliases ) {
if (aliase.entity() != void.class) { if ( aliase.entity() != void.class ) {
ret.put(aliase.alias(), aliase.entity().getName()); ret.put( aliase.alias(), aliase.entity().getName() );
} }
} }
return ret; return ret;

View File

@ -247,8 +247,8 @@ public abstract class ExternalSessionFactoryConfig {
String[] mappingFiles = ConfigurationHelper.toStringArray( mapResources, " ,\n\t\r\f" ); String[] mappingFiles = ConfigurationHelper.toStringArray( mapResources, " ,\n\t\r\f" );
for (String mappingFile : mappingFiles) { for ( String mappingFile : mappingFiles ) {
cfg.addResource(mappingFile); cfg.addResource( mappingFile );
} }
return cfg; return cfg;

View File

@ -66,8 +66,8 @@ public class IndexOrUniqueKeySecondPass implements SecondPass {
@Override @Override
public void doSecondPass(Map persistentClasses) throws MappingException { public void doSecondPass(Map persistentClasses) throws MappingException {
if ( columns != null ) { if ( columns != null ) {
for (String column1 : columns) { for ( String column1 : columns ) {
addConstraintToColumn(column1); addConstraintToColumn( column1 );
} }
} }
if ( column != null ) { if ( column != null ) {

View File

@ -163,8 +163,8 @@ public class HQLQueryPlan implements Serializable {
*/ */
public String[] getSqlStrings() { public String[] getSqlStrings() {
List<String> sqlStrings = new ArrayList<>(); List<String> sqlStrings = new ArrayList<>();
for (QueryTranslator translator : translators) { for ( QueryTranslator translator : translators ) {
sqlStrings.addAll(translator.collectSqlStrings()); sqlStrings.addAll( translator.collectSqlStrings() );
} }
return ArrayHelper.toStringArray( sqlStrings ); return ArrayHelper.toStringArray( sqlStrings );
} }

View File

@ -236,7 +236,7 @@ public class NamedSQLQueryDefinition extends NamedQueryDefinition {
allQueryReturns[i] = this.queryReturns[i]; allQueryReturns[i] = this.queryReturns[i];
} }
for (NativeSQLQueryReturn queryReturnsToAdd1 : queryReturnsToAdd) { for ( NativeSQLQueryReturn queryReturnsToAdd1 : queryReturnsToAdd ) {
allQueryReturns[i] = queryReturnsToAdd1; allQueryReturns[i] = queryReturnsToAdd1;
i++; i++;
} }

View File

@ -343,10 +343,10 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa
final String[] propertyNames = getIdentifierPropertyNames(); final String[] propertyNames = getIdentifierPropertyNames();
List<String> columns = new ArrayList<>(); List<String> columns = new ArrayList<>();
final boolean inSelect = getWalker().getStatementType() == HqlSqlTokenTypes.SELECT; final boolean inSelect = getWalker().getStatementType() == HqlSqlTokenTypes.SELECT;
for (String propertyName : propertyNames) { for ( String propertyName : propertyNames ) {
String[] propertyNameColumns = toColumns(table, propertyName, inSelect); String[] propertyNameColumns = toColumns( table, propertyName, inSelect );
for (String propertyNameColumn : propertyNameColumns) { for ( String propertyNameColumn : propertyNameColumns ) {
columns.add(propertyNameColumn); columns.add( propertyNameColumn );
} }
} }
return columns.toArray( new String[columns.size()] ); return columns.toArray( new String[columns.size()] );

View File

@ -161,8 +161,8 @@ public class IntoClause extends HqlSqlWalkerNode implements DisplayableNode {
if ( componentIds == null ) { if ( componentIds == null ) {
String[] propertyNames = ( (CompositeType) persister.getIdentifierType() ).getPropertyNames(); String[] propertyNames = ( (CompositeType) persister.getIdentifierType() ).getPropertyNames();
componentIds = new HashSet(); componentIds = new HashSet();
for (String propertyName : propertyNames) { for ( String propertyName : propertyNames ) {
componentIds.add(propertyName); componentIds.add( propertyName );
} }
} }
if ( componentIds.contains( name ) ) { if ( componentIds.contains( name ) ) {
@ -194,7 +194,7 @@ public class IntoClause extends HqlSqlWalkerNode implements DisplayableNode {
} }
private void renderColumns(String[] columnNames) { private void renderColumns(String[] columnNames) {
for (String columnName : columnNames) { for ( String columnName : columnNames ) {
columnSpec += columnName + ", "; columnSpec += columnName + ", ";
} }
} }

View File

@ -143,8 +143,9 @@ public class TableBasedUpdateHandlerImpl
ps = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( updates[i], false ); ps = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( updates[i], false );
if ( assignmentParameterSpecifications[i] != null ) { if ( assignmentParameterSpecifications[i] != null ) {
int position = 1; // jdbc params are 1-based int position = 1; // jdbc params are 1-based
for (ParameterSpecification assignmentParameterSpecification : assignmentParameterSpecifications[i]) { for ( ParameterSpecification assignmentParameterSpecification : assignmentParameterSpecifications[i] ) {
position += assignmentParameterSpecification.bind(ps, queryParameters, session, position); position += assignmentParameterSpecification
.bind( ps, queryParameters, session, position );
} }
handleAddedParametersOnUpdate( ps, session, position ); handleAddedParametersOnUpdate( ps, session, position );
} }

View File

@ -112,8 +112,9 @@ public class CteValuesListUpdateHandlerImpl
} }
} }
if ( assignmentParameterSpecifications[i] != null ) { if ( assignmentParameterSpecifications[i] != null ) {
for (ParameterSpecification assignmentParameterSpecification : assignmentParameterSpecifications[i]) { for ( ParameterSpecification assignmentParameterSpecification : assignmentParameterSpecifications[i] ) {
position += assignmentParameterSpecification.bind(ps, queryParameters, session, position); position += assignmentParameterSpecification
.bind( ps, queryParameters, session, position );
} }
} }
session session

View File

@ -103,8 +103,9 @@ public abstract class AbstractInlineIdsUpdateHandlerImpl
.prepareStatement( update, false )) { .prepareStatement( update, false )) {
int position = 1; // jdbc params are 1-based int position = 1; // jdbc params are 1-based
if ( assignmentParameterSpecifications[i] != null ) { if ( assignmentParameterSpecifications[i] != null ) {
for (ParameterSpecification assignmentParameterSpecification : assignmentParameterSpecifications[i]) { for ( ParameterSpecification assignmentParameterSpecification : assignmentParameterSpecifications[i] ) {
position += assignmentParameterSpecification.bind(ps, queryParameters, session, position); position += assignmentParameterSpecification
.bind( ps, queryParameters, session, position );
} }
} }
jdbcCoordinator.getResultSetReturn() jdbcCoordinator.getResultSetReturn()

View File

@ -5264,8 +5264,8 @@ public abstract class AbstractEntityPersister
if ( attribute.getType() instanceof ComponentType ) { if ( attribute.getType() instanceof ComponentType ) {
final ComponentType type = (ComponentType) attribute.getType(); final ComponentType type = (ComponentType) attribute.getType();
final ValueGeneration[] propertyValueGenerationStrategies = type.getPropertyValueGenerationStrategies(); final ValueGeneration[] propertyValueGenerationStrategies = type.getPropertyValueGenerationStrategies();
for (ValueGeneration propertyValueGenerationStrategie : propertyValueGenerationStrategies) { for ( ValueGeneration propertyValueGenerationStrategie : propertyValueGenerationStrategies ) {
if (isReadRequired(propertyValueGenerationStrategie, matchTiming)) { if ( isReadRequired( propertyValueGenerationStrategie, matchTiming ) ) {
return true; return true;
} }
} }

View File

@ -38,12 +38,12 @@ public class Insert {
} }
public Insert addColumn(String columnName) { public Insert addColumn(String columnName) {
return addColumn(columnName, "?"); return addColumn( columnName, "?" );
} }
public Insert addColumns(String[] columnNames) { public Insert addColumns(String[] columnNames) {
for (String columnName : columnNames) { for ( String columnName : columnNames ) {
addColumn(columnName); addColumn( columnName );
} }
return this; return this;
} }
@ -67,12 +67,12 @@ public class Insert {
} }
public Insert addColumn(String columnName, String valueExpression) { public Insert addColumn(String columnName, String valueExpression) {
columns.put(columnName, valueExpression); columns.put( columnName, valueExpression );
return this; return this;
} }
public Insert addColumn(String columnName, Object value, LiteralType type) throws Exception { public Insert addColumn(String columnName, Object value, LiteralType type) throws Exception {
return addColumn( columnName, type.objectToSQLString(value, dialect) ); return addColumn( columnName, type.objectToSQLString( value, dialect ) );
} }
public Insert addIdentityColumn(String columnName) { public Insert addIdentityColumn(String columnName) {

View File

@ -44,8 +44,8 @@ public class InsertSelect {
} }
public InsertSelect addColumns(String[] columnNames) { public InsertSelect addColumns(String[] columnNames) {
for (String columnName : columnNames) { for ( String columnName : columnNames ) {
this.columnNames.add(columnName); this.columnNames.add( columnName );
} }
return this; return this;
} }

View File

@ -88,10 +88,12 @@ public class QueryJoinFragment extends JoinFragment {
} }
public void addCondition(String alias, String[] columns, String condition) { public void addCondition(String alias, String[] columns, String condition) {
for (String column : columns) { for ( String column : columns ) {
afterWhere.append( " and " ) afterWhere.append( " and " )
.append( alias ) .append( alias )
.append( '.' ).append(column).append(condition); .append( '.' )
.append( column )
.append( condition );
} }
} }

View File

@ -530,8 +530,8 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
if ( "TABLE".equalsIgnoreCase( tableType ) ) { if ( "TABLE".equalsIgnoreCase( tableType ) ) {
return true; return true;
} }
for (String extraPhysicalTableType : extraPhysicalTableTypes) { for ( String extraPhysicalTableType : extraPhysicalTableTypes ) {
if (extraPhysicalTableType.equalsIgnoreCase(tableType)) { if ( extraPhysicalTableType.equalsIgnoreCase( tableType ) ) {
return true; return true;
} }
} }

View File

@ -832,8 +832,8 @@ public class EntityMetamodel implements Serializable {
} }
else if ( type.isComponentType() ) { else if ( type.isComponentType() ) {
Type[] subtypes = ( (CompositeType) type ).getSubtypes(); Type[] subtypes = ( (CompositeType) type ).getSubtypes();
for (Type subtype : subtypes) { for ( Type subtype : subtypes ) {
if (indicatesCollection(subtype)) { if ( indicatesCollection( subtype ) ) {
return true; return true;
} }
} }

View File

@ -8,11 +8,6 @@
//$Id: FumTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $ //$Id: FumTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
package org.hibernate.test.legacy; package org.hibernate.test.legacy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -21,7 +16,6 @@ import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -51,18 +45,22 @@ import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PointbaseDialect; import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.TimesTenDialect; import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.transform.Transformers; import org.hibernate.transform.Transformers;
import org.hibernate.type.CalendarType;
import org.hibernate.type.EntityType; import org.hibernate.type.EntityType;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.StringType; import org.hibernate.type.StringType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@RequiresDialectFeature(DialectChecks.SupportsNoColumnInsert.class) @RequiresDialectFeature(DialectChecks.SupportsNoColumnInsert.class)
public class FumTest extends LegacyTestCase { public class FumTest extends LegacyTestCase {
private static short fumKeyShort = 1; private static short fumKeyShort = 1;
@ -470,13 +468,13 @@ public class FumTest extends LegacyTestCase {
); );
Query qu = s.createQuery("select fum.fum, fum , fum.fum from Fum fum"); Query qu = s.createQuery("select fum.fum, fum , fum.fum from Fum fum");
Type[] types = qu.getReturnTypes(); Type[] types = qu.getReturnTypes();
assertTrue(types.length==3); assertTrue( types.length == 3 );
for (Type type : types) { for ( Type type : types ) {
assertTrue(type != null); assertTrue( type != null );
} }
assertTrue(types[0] instanceof StringType); assertTrue( types[0] instanceof StringType );
assertTrue(types[1] instanceof EntityType); assertTrue( types[1] instanceof EntityType );
assertTrue(types[2] instanceof StringType); assertTrue( types[2] instanceof StringType );
Iterator iter = qu.iterate(); Iterator iter = qu.iterate();
int j = 0; int j = 0;
while ( iter.hasNext() ) { while ( iter.hasNext() ) {

View File

@ -6,16 +6,14 @@
*/ */
package org.hibernate.test.schemaupdate; package org.hibernate.test.schemaupdate;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.ForeignKey;
import org.hibernate.boot.MetadataSources; import org.hibernate.boot.MetadataSources;
@ -23,9 +21,10 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.tool.schema.internal.SchemaCreatorImpl; import org.hibernate.tool.schema.internal.SchemaCreatorImpl;
import org.hibernate.testing.TestForIssue;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.TestForIssue; import org.apache.log4j.Logger;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -57,8 +56,8 @@ public class ImplicitCompositeKeyJoinTest {
if ( command.toLowerCase().matches( "^create( (column|row))? table employee.+" ) ) { if ( command.toLowerCase().matches( "^create( (column|row))? table employee.+" ) ) {
final String[] columnsDefinition = getColumnsDefinition( command ); final String[] columnsDefinition = getColumnsDefinition( command );
for (String columnsDefinition1 : columnsDefinition) { for ( String columnsDefinition1 : columnsDefinition ) {
checkColumnSize(columnsDefinition1); checkColumnSize( columnsDefinition1 );
} }
createTableEmployeeFound = true; createTableEmployeeFound = true;
} }

View File

@ -35,8 +35,6 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -45,8 +43,10 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -102,22 +102,22 @@ public class SubselectFetchCollectionFromBatchTest extends BaseCoreFunctionalTe
assertEquals( 0, sessionFactory().getStatistics().getPrepareStatementCount() ); assertEquals( 0, sessionFactory().getStatistics().getPrepareStatementCount() );
for (EmployeeGroup group : groups) { for ( EmployeeGroup group : groups ) {
// Both groups get initialized and are added to the PersistenceContext when i == 0; // Both groups get initialized and are added to the PersistenceContext when i == 0;
// Still need to call Hibernate.initialize( groups[i] ) for i > 0 so that the entity // Still need to call Hibernate.initialize( groups[i] ) for i > 0 so that the entity
// in the PersistenceContext gets assigned to its respective proxy target (is this a // in the PersistenceContext gets assigned to its respective proxy target (is this a
// bug???) // bug???)
Hibernate.initialize(group); Hibernate.initialize( group );
assertTrue(Hibernate.isInitialized(group)); assertTrue( Hibernate.isInitialized( group ) );
// the collections should be uninitialized // the collections should be uninitialized
assertFalse(Hibernate.isInitialized(group.getEmployees())); assertFalse( Hibernate.isInitialized( group.getEmployees() ) );
} }
// both Group proxies should have been loaded in the same batch; // both Group proxies should have been loaded in the same batch;
assertEquals( 1, sessionFactory().getStatistics().getPrepareStatementCount() ); assertEquals( 1, sessionFactory().getStatistics().getPrepareStatementCount() );
sessionFactory().getStatistics().clear(); sessionFactory().getStatistics().clear();
for (EmployeeGroup group : groups) { for ( EmployeeGroup group : groups ) {
assertTrue( Hibernate.isInitialized( group ) ); assertTrue( Hibernate.isInitialized( group ) );
assertFalse( Hibernate.isInitialized( group.getEmployees() ) ); assertFalse( Hibernate.isInitialized( group.getEmployees() ) );
} }
@ -250,26 +250,26 @@ public class SubselectFetchCollectionFromBatchTest extends BaseCoreFunctionalTe
assertEquals( 0, sessionFactory().getStatistics().getPrepareStatementCount() ); assertEquals( 0, sessionFactory().getStatistics().getPrepareStatementCount() );
for (EmployeeGroup group : groups) { for ( EmployeeGroup group : groups ) {
// Both groups get initialized and are added to the PersistenceContext when i == 0; // Both groups get initialized and are added to the PersistenceContext when i == 0;
// Still need to call Hibernate.initialize( groups[i] ) for i > 0 so that the entity // Still need to call Hibernate.initialize( groups[i] ) for i > 0 so that the entity
// in the PersistenceContext gets assigned to its respective proxy target (is this a // in the PersistenceContext gets assigned to its respective proxy target (is this a
// bug???) // bug???)
Hibernate.initialize(group); Hibernate.initialize( group );
assertTrue(Hibernate.isInitialized(group)); assertTrue( Hibernate.isInitialized( group ) );
assertTrue(Hibernate.isInitialized(group.getLead())); assertTrue( Hibernate.isInitialized( group.getLead() ) );
assertFalse(Hibernate.isInitialized(group.getLead().getCollaborators())); assertFalse( Hibernate.isInitialized( group.getLead().getCollaborators() ) );
assertTrue(Hibernate.isInitialized(group.getManager())); assertTrue( Hibernate.isInitialized( group.getManager() ) );
assertFalse(Hibernate.isInitialized(group.getManager().getCollaborators())); assertFalse( Hibernate.isInitialized( group.getManager().getCollaborators() ) );
// the collections should be uninitialized // the collections should be uninitialized
assertFalse(Hibernate.isInitialized(group.getEmployees())); assertFalse( Hibernate.isInitialized( group.getEmployees() ) );
} }
// both Group proxies should have been loaded in the same batch; // both Group proxies should have been loaded in the same batch;
assertEquals( 1, sessionFactory().getStatistics().getPrepareStatementCount() ); assertEquals( 1, sessionFactory().getStatistics().getPrepareStatementCount() );
sessionFactory().getStatistics().clear(); sessionFactory().getStatistics().clear();
for (EmployeeGroup group : groups) { for ( EmployeeGroup group : groups ) {
assertTrue( Hibernate.isInitialized( group ) ); assertTrue( Hibernate.isInitialized( group ) );
assertFalse( Hibernate.isInitialized( group.getEmployees() ) ); assertFalse( Hibernate.isInitialized( group.getEmployees() ) );
} }

View File

@ -73,7 +73,7 @@ public final class ExtraAssertions {
private static Map generateJdbcTypeCache() { private static Map generateJdbcTypeCache() {
final Field[] fields = Types.class.getFields(); final Field[] fields = Types.class.getFields();
Map cache = new HashMap( (int)( fields.length * .75 ) + 1 ); Map cache = new HashMap( (int)( fields.length * .75 ) + 1 );
for (Field field : fields) { for ( Field field : fields ) {
if ( Modifier.isStatic( field.getModifiers() ) ) { if ( Modifier.isStatic( field.getModifiers() ) ) {
try { try {
cache.put( field.get( null ), field.getName() ); cache.put( field.get( null ), field.getName() );