Fix issue with DatabaseSnapshotExecutor not returning the correct array
This commit is contained in:
parent
45328a574b
commit
34a5274b3f
|
@ -43,7 +43,7 @@ import org.hibernate.sql.exec.spi.JdbcParameterBindings;
|
||||||
import org.hibernate.sql.exec.spi.JdbcSelect;
|
import org.hibernate.sql.exec.spi.JdbcSelect;
|
||||||
import org.hibernate.sql.results.graph.DomainResult;
|
import org.hibernate.sql.results.graph.DomainResult;
|
||||||
import org.hibernate.sql.results.graph.basic.BasicResult;
|
import org.hibernate.sql.results.graph.basic.BasicResult;
|
||||||
import org.hibernate.sql.results.internal.RowTransformerPassThruImpl;
|
import org.hibernate.sql.results.internal.RowTransformerDatabaseSnapshotImpl;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ class DatabaseSnapshotExecutor {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
RowTransformerPassThruImpl.instance(),
|
RowTransformerDatabaseSnapshotImpl.instance(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -251,12 +251,14 @@ class DatabaseSnapshotExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int size = list.size();
|
final int size = list.size();
|
||||||
final Object[] values = new Object[size];
|
assert size <= 1;
|
||||||
for ( int i = 0; i < size; i++ ) {
|
|
||||||
values[i] = list.get( i );
|
|
||||||
}
|
|
||||||
|
|
||||||
return values;
|
if ( size == 0 ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (Object[]) list.get( 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -673,7 +673,7 @@ public abstract class Collection implements Fetchable, Value, Filterable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasAnyUpdatableColumns() {
|
public boolean hasAnyUpdatableColumns() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubselectLoadable() {
|
public boolean isSubselectLoadable() {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.mapping.ManyToOne;
|
||||||
import org.hibernate.mapping.OneToOne;
|
import org.hibernate.mapping.OneToOne;
|
||||||
import org.hibernate.mapping.ToOne;
|
import org.hibernate.mapping.ToOne;
|
||||||
import org.hibernate.metamodel.mapping.AssociationKey;
|
import org.hibernate.metamodel.mapping.AssociationKey;
|
||||||
|
import org.hibernate.metamodel.mapping.ColumnConsumer;
|
||||||
import org.hibernate.metamodel.mapping.EntityAssociationMapping;
|
import org.hibernate.metamodel.mapping.EntityAssociationMapping;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||||
|
@ -612,4 +613,11 @@ public class ToOneAttributeMapping extends AbstractSingularAttributeMapping
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SingularAssociationAttributeMapping {" + navigableRole + "}";
|
return "SingularAssociationAttributeMapping {" + navigableRole + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitColumns(ColumnConsumer consumer) {
|
||||||
|
if ( foreignKeyDirection == ForeignKeyDirection.FROM_PARENT ) {
|
||||||
|
foreignKeyDescriptor.visitReferringColumns( consumer );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.sql.results.internal;
|
||||||
|
|
||||||
|
import org.hibernate.sql.results.spi.RowTransformer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrea Boriero
|
||||||
|
*/
|
||||||
|
public class RowTransformerDatabaseSnapshotImpl<T> implements RowTransformer<T> {
|
||||||
|
/**
|
||||||
|
* Singleton access
|
||||||
|
*/
|
||||||
|
public static final RowTransformerDatabaseSnapshotImpl INSTANCE = new RowTransformerDatabaseSnapshotImpl();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> RowTransformerDatabaseSnapshotImpl<T> instance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RowTransformerDatabaseSnapshotImpl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public T transformRow(Object[] row) {
|
||||||
|
return (T) row;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue