Throw UnknownSqlResultSetMappingException for non existing StoreProcedure result mapping
This commit is contained in:
parent
b139967be1
commit
5446291171
|
@ -11,6 +11,7 @@ import java.util.function.Consumer;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.query.UnknownSqlResultSetMappingException;
|
||||||
import org.hibernate.query.internal.ResultSetMappingResolutionContext;
|
import org.hibernate.query.internal.ResultSetMappingResolutionContext;
|
||||||
import org.hibernate.query.named.NamedObjectRepository;
|
import org.hibernate.query.named.NamedObjectRepository;
|
||||||
import org.hibernate.query.named.NamedResultSetMappingMemento;
|
import org.hibernate.query.named.NamedResultSetMappingMemento;
|
||||||
|
@ -57,6 +58,9 @@ public class Util {
|
||||||
|
|
||||||
for ( String resultSetMappingName : resultSetMappingNames ) {
|
for ( String resultSetMappingName : resultSetMappingNames ) {
|
||||||
final NamedResultSetMappingMemento memento = namedObjectRepository.getResultSetMappingMemento( resultSetMappingName );
|
final NamedResultSetMappingMemento memento = namedObjectRepository.getResultSetMappingMemento( resultSetMappingName );
|
||||||
|
if ( memento == null ) {
|
||||||
|
throw new UnknownSqlResultSetMappingException( "Unknown SqlResultSetMapping [" + resultSetMappingName + "]" );
|
||||||
|
}
|
||||||
memento.resolve(
|
memento.resolve(
|
||||||
resultSetMapping,
|
resultSetMapping,
|
||||||
querySpaceConsumer,
|
querySpaceConsumer,
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.jpa.compliance;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@Jpa
|
||||||
|
public class StoreProcedureTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createNotExistingStoredProcedureQuery(EntityManagerFactoryScope scope) {
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
|
entityManager -> {
|
||||||
|
Assertions.assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> {
|
||||||
|
entityManager.createStoredProcedureQuery(
|
||||||
|
"NOT_EXISTING_NAME",
|
||||||
|
"NOT_EXISTING_RESULT_MAPPING"
|
||||||
|
)
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue