re-enable tests

This commit is contained in:
Steve Ebersole 2021-03-19 15:25:08 -05:00
parent 2589671fa1
commit 12fb58f6b9
30 changed files with 109 additions and 146 deletions

View File

@ -2896,14 +2896,19 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
@Override
public SqmExpression<?> visitJpaNonStandardFunction(HqlParser.JpaNonStandardFunctionContext ctx) {
final String functionName = ctx.jpaNonStandardFunctionName().STRING_LITERAL().getText().toLowerCase();
List<SqmTypedNode<?>> functionArguments =
ctx.nonStandardFunctionArguments() == null ? emptyList() :
(List<SqmTypedNode<?>>) ctx.nonStandardFunctionArguments().accept( this );
//noinspection unchecked
final List<SqmTypedNode<?>> functionArguments = ctx.nonStandardFunctionArguments() == null
? emptyList()
: (List<SqmTypedNode<?>>) ctx.nonStandardFunctionArguments().accept( this );
SqmFunctionDescriptor functionTemplate = getFunctionDescriptor( functionName );
if (functionTemplate == null) {
functionTemplate = new NamedSqmFunctionDescriptor( functionName, true, null,
StandardFunctionReturnTypeResolvers.invariant( StandardBasicTypes.OBJECT_TYPE ) );
functionTemplate = new NamedSqmFunctionDescriptor(
functionName,
true,
null,
StandardFunctionReturnTypeResolvers.invariant( StandardBasicTypes.OBJECT_TYPE )
);
}
return functionTemplate.generateSqmExpression(
functionArguments,
@ -2918,21 +2923,29 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
if ( creationOptions.useStrictJpaCompliance() ) {
throw new StrictJpaComplianceViolation(
"Encountered non-compliant non-standard function call [" +
ctx.nonStandardFunctionName() + "], but strict JPQL compliance was requested; use JPA's FUNCTION(functionName[,...]) syntax name instead",
ctx.nonStandardFunctionName() + "], but strict JPA " +
"compliance was requested; use JPA's FUNCTION(functionName[,...]) " +
"syntax name instead",
StrictJpaComplianceViolation.Type.FUNCTION_CALL
);
}
final String functionName = ctx.nonStandardFunctionName().getText().toLowerCase();
List<SqmTypedNode<?>> functionArguments =
ctx.nonStandardFunctionArguments() == null ? emptyList() :
(List<SqmTypedNode<?>>) ctx.nonStandardFunctionArguments().accept( this );
//noinspection unchecked
final List<SqmTypedNode<?>> functionArguments = ctx.nonStandardFunctionArguments() == null
? emptyList()
: (List<SqmTypedNode<?>>) ctx.nonStandardFunctionArguments().accept( this );
SqmFunctionDescriptor functionTemplate = getFunctionDescriptor(functionName);
if (functionTemplate == null) {
functionTemplate = new NamedSqmFunctionDescriptor( functionName, true, null,
StandardFunctionReturnTypeResolvers.invariant( StandardBasicTypes.OBJECT_TYPE ) );
SqmFunctionDescriptor functionTemplate = getFunctionDescriptor( functionName );
if ( functionTemplate == null ) {
functionTemplate = new NamedSqmFunctionDescriptor(
functionName,
true,
null,
StandardFunctionReturnTypeResolvers.invariant( StandardBasicTypes.OBJECT_TYPE )
);
}
return functionTemplate.generateSqmExpression(
functionArguments,
null,

View File

@ -1,85 +0,0 @@
/*
* 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.boot.spi.metadatabuildercontributor;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.annotations.NaturalId;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.util.ExceptionUtil;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Vlad Mihalcea
*/
@RequiresDialect(H2Dialect.class)
@TestForIssue( jiraKey = "HHH-12589" )
public class SqlFunctionMissingTest extends BaseEntityManagerFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Employee.class,
};
}
final Employee employee = new Employee();
@Override
protected void afterEntityManagerFactoryBuilt() {
doInJPA( this::entityManagerFactory, entityManager -> {
employee.id = 1L;
employee.username = "user@acme.com";
entityManager.persist( employee );
} );
}
@Test
public void test() {
try {
doInJPA( this::entityManagerFactory, entityManager -> {
Number result = (Number) entityManager.createQuery(
"select INSTR(e.username,'@') " +
"from Employee e " +
"where " +
" e.id = :employeeId")
.setParameter( "employeeId", employee.id )
.getSingleResult();
fail("Should throw exception!");
} );
}
catch (Exception expected) {
assertTrue( ExceptionUtil.rootCause( expected ).getMessage().contains( "No data type for node: org.hibernate.hql.internal.ast.tree.MethodNod" ) );
}
}
@Entity(name = "Employee")
public static class Employee {
@Id
private Long id;
@NaturalId
private String username;
private String password;
}
}

View File

@ -1,4 +1,10 @@
package org.hibernate.boot.model.source.internal.hbm;
/*
* 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.bootstrap.binding.mixed;
import javax.persistence.*;

View File

@ -1,4 +1,10 @@
package org.hibernate.boot.model.source.internal.hbm;
/*
* 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.bootstrap.binding.mixed;
public class HBMEntity {

View File

@ -1,4 +1,10 @@
package org.hibernate.boot.model.source.internal.hbm;
/*
* 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.bootstrap.binding.mixed;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.junit.Assert;
@ -27,7 +33,7 @@ public class HBMManyToOneAnnotationMissingPrimaryKeyTest extends BaseNonConfigCo
@Override
protected String getBaseForMappings() {
return "/org/hibernate/boot/model/source/internal/hbm/";
return "/org/hibernate/orm/test/bootstrap/binding/mixed/";
}
/**

View File

@ -1,10 +1,10 @@
/*
* 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>.
* 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.boot.model.source.internal.hbm;
package org.hibernate.orm.test.bootstrap.binding.mixed;
import java.util.Map;
@ -41,7 +41,7 @@ public class XMLMappingDisabledTest extends BaseNonConfigCoreFunctionalTestCase
@Override
protected String getBaseForMappings() {
return "/org/hibernate/boot/model/source/internal/hbm/";
return "/org/hibernate/orm/test/bootstrap/binding/mixed/";
}
@Override

View File

@ -0,0 +1,11 @@
/*
* 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
*/
/**
* Tests for verifying mixed use of HBM and annotations
*/
package org.hibernate.orm.test.bootstrap.binding.mixed;

View File

@ -1,10 +1,13 @@
/*
* 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>.
* 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.boot.model.naming;
package org.hibernate.orm.test.bootstrap.binding.naming;
import org.hibernate.boot.model.naming.ImplicitIndexColumnNameSource;
import org.hibernate.boot.model.naming.ImplicitNameSource;
import org.hibernate.testing.TestForIssue;
import org.junit.Test;

View File

@ -1,14 +1,17 @@
/*
* 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>.
* 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.boot.model.naming;
package org.hibernate.orm.test.bootstrap.binding.naming;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.NamingHelper;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.testing.util.ReflectionUtil;

View File

@ -1,10 +1,10 @@
/*
* 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>.
* 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.boot.registry.classloading.internal;
package org.hibernate.orm.test.bootstrap.registry.classloading;
import java.net.URL;
import java.util.ArrayList;
@ -12,6 +12,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
import org.hibernate.testing.TestForIssue;
import org.junit.Test;

View File

@ -4,7 +4,7 @@
* 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.boot.registry.classloading.internal;
package org.hibernate.orm.test.bootstrap.registry.classloading;
import java.io.IOException;
import java.io.InputStream;

View File

@ -4,7 +4,7 @@
* 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.boot.registry.classloading.internal;
package org.hibernate.orm.test.bootstrap.registry.classloading;
import org.hibernate.service.Service;

View File

@ -4,7 +4,7 @@
* 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.boot.registry.classloading.internal;
package org.hibernate.orm.test.bootstrap.registry.classloading;
public class MyServiceImpl implements MyService {
}

View File

@ -4,7 +4,7 @@
* 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.boot.spi.delegation;
package org.hibernate.orm.test.bootstrap.spi.delegation;
import org.hibernate.boot.spi.AbstractDelegatingMetadata;
import org.hibernate.boot.spi.MetadataImplementor;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.delegation;
package org.hibernate.orm.test.bootstrap.spi.delegation;
import org.hibernate.boot.spi.AbstractDelegatingMetadataBuilderImplementor;
import org.hibernate.boot.spi.BootstrapContext;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.delegation;
package org.hibernate.orm.test.bootstrap.spi.delegation;
import org.hibernate.boot.spi.AbstractDelegatingMetadataBuildingOptions;
import org.hibernate.boot.spi.MetadataBuildingOptions;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.delegation;
package org.hibernate.orm.test.bootstrap.spi.delegation;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.spi.AbstractDelegatingSessionFactoryBuilder;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.delegation;
package org.hibernate.orm.test.bootstrap.spi.delegation;
import org.hibernate.boot.spi.AbstractDelegatingSessionFactoryBuilderImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.delegation;
package org.hibernate.orm.test.bootstrap.spi.delegation;
import org.hibernate.boot.spi.AbstractDelegatingSessionFactoryOptions;
import org.hibernate.boot.spi.SessionFactoryOptions;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import java.util.Map;
import javax.persistence.Entity;
@ -61,15 +61,15 @@ public abstract class AbstractSqlFunctionMetadataBuilderContributorTest extends
@Test
public void test() {
doInJPA( this::entityManagerFactory, entityManager -> {
String result = (String) entityManager.createQuery(
int result = entityManager.createQuery(
"select INSTR(e.username,'@acme.com') " +
"from Employee e " +
"where " +
" e.id = :employeeId")
" e.id = :employeeId", Integer.class )
.setParameter( "employeeId", employee.id )
.getSingleResult();
assertEquals( "5", result );
assertEquals( 5, result );
} );
}

View File

@ -4,7 +4,7 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import java.time.YearMonth;
import java.util.Map;

View File

@ -1,4 +1,4 @@
package org.hibernate.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import org.hibernate.boot.MetadataBuilder;
import org.hibernate.boot.spi.MetadataBuilderContributor;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import org.hibernate.dialect.H2Dialect;

View File

@ -4,20 +4,12 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.annotations.NaturalId;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;

View File

@ -4,11 +4,10 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import org.hibernate.dialect.H2Dialect;

View File

@ -4,7 +4,7 @@
* 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.boot.spi.metadatabuildercontributor;
package org.hibernate.orm.test.bootstrap.spi.metadatabuildercontributor;
import org.hibernate.dialect.H2Dialect;

View File

@ -1 +0,0 @@
org.hibernate.boot.registry.classloading.internal.MyServiceImpl

View File

@ -0,0 +1 @@
org.hibernate.orm.test.bootstrap.registry.classloading.MyServiceImpl

View File

@ -1,9 +1,15 @@
<?xml version="1.0"?>
<!--
~ 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
-->
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.boot.model.source.internal.hbm">
<hibernate-mapping package="org.hibernate.orm.test.bootstrap.binding.mixed">
<class name="HBMEntity" table="hbmentity" >
<id name="id" unsaved-value="0">
<generator class="sequence">