6 - SQM based on JPA type system

This commit is contained in:
Andrea Boriero 2019-07-25 17:39:32 +01:00
parent b101ffbf79
commit c45108a2b6
17 changed files with 28 additions and 61 deletions

View File

@ -46,7 +46,8 @@ dependencies {
testCompile( 'org.apache.commons:commons-lang3:3.4' )
testCompile( project(':hibernate-envers') )
testCompile( project(':hibernate-spatial') )
// todo (6.0) - add back hibernate-spatial dependency
// testCompile( project(':hibernate-spatial') )
testCompile( project(path: ':hibernate-core', configuration: 'tests') )
testCompile( project(':hibernate-testing') )

View File

@ -247,7 +247,7 @@ public class BatchTest extends BaseEntityManagerFunctionalTestCase {
int count = 0;
while ( scrollableResults.next() ) {
Person Person = (Person) scrollableResults.get( 0 );
Person Person = (Person) scrollableResults.get( );
processPerson(Person);
if ( ++count % batchSize == 0 ) {
//flush a batch of updates and release memory:
@ -290,7 +290,7 @@ public class BatchTest extends BaseEntityManagerFunctionalTestCase {
.scroll(ScrollMode.FORWARD_ONLY);
while ( scrollableResults.next() ) {
Person Person = (Person) scrollableResults.get( 0 );
Person Person = (Person) scrollableResults.get();
processPerson(Person);
statelessSession.update( Person );
}

View File

@ -24,9 +24,6 @@ import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.Session;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.userguide.model.AddressType;
import org.hibernate.userguide.model.Call;
@ -401,39 +398,6 @@ public class CriteriaTest extends BaseEntityManagerFunctionalTestCase {
});
}
@Test
public void testLegacyCriteriaJpavsHibernateEntityName() {
doInJPA( this::entityManagerFactory, entityManager -> {
Event event1 = new Event();
event1.id = 1L;
event1.name = "E1";
entityManager.persist( event1 );
Event event2 = new Event();
event2.id = 2L;
event2.name = "E2";
entityManager.persist( event2 );
List<String> eventNames = entityManager.unwrap( Session.class )
.createQuery( "select ae.name from ApplicationEvent ae" )
.list();
try {
List<Event> events = entityManager.unwrap( Session.class )
.createCriteria( "ApplicationEvent" )
.list();
}
catch ( MappingException expected ) {
assertEquals( "Unknown entity: ApplicationEvent", expected.getMessage() );
}
List<Event> events = entityManager.unwrap( Session.class )
.createCriteria( Event.class.getName() )
.list();
});
}
@Entity(name = "ApplicationEvent")
public static class Event {

View File

@ -868,7 +868,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
.scroll()
) {
while(scrollableResults.next()) {
Person person = (Person) scrollableResults.get()[0];
Person person = (Person) scrollableResults.get();
process(person);
}
}

View File

@ -17,6 +17,7 @@ import org.hibernate.Session;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.procedure.ProcedureCall;
import org.hibernate.query.procedure.ProcedureParameter;
import org.hibernate.result.Output;
import org.hibernate.result.ResultSetOutput;
import org.hibernate.userguide.model.AddressType;
@ -181,7 +182,8 @@ public class MySQLStoredProcedureTest extends BaseEntityManagerFunctionalTestCas
Session session = entityManager.unwrap( Session.class );
ProcedureCall call = session.createStoredProcedureCall( "sp_count_phones" );
call.registerParameter( "personId", Long.class, ParameterMode.IN ).bindValue( 1L );
ProcedureParameter<Long> parameter = call.registerParameter( "personId", Long.class, ParameterMode.IN );
call.setParameter( parameter, 1L );
call.registerParameter( "phoneCount", Long.class, ParameterMode.OUT );
Long phoneCount = (Long) call.getOutputs().getOutputParameterValue( "phoneCount" );
@ -230,7 +232,8 @@ public class MySQLStoredProcedureTest extends BaseEntityManagerFunctionalTestCas
Session session = entityManager.unwrap( Session.class );
ProcedureCall call = session.createStoredProcedureCall( "sp_phones" );
call.registerParameter( 1, Long.class, ParameterMode.IN ).bindValue( 1L );
ProcedureParameter<Long> parameter = call.registerParameter( 1, Long.class, ParameterMode.IN );
call.setParameter(parameter, 1L );
Output output = call.getOutputs().getCurrent();

View File

@ -14,6 +14,7 @@ import org.hibernate.Session;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.procedure.ProcedureCall;
import org.hibernate.query.procedure.ProcedureParameter;
import org.hibernate.result.Output;
import org.hibernate.result.ResultSetOutput;
import org.hibernate.userguide.model.AddressType;
@ -205,7 +206,8 @@ public class OracleStoredProcedureTest extends BaseEntityManagerFunctionalTestCa
Session session = entityManager.unwrap(Session.class);
ProcedureCall call = session.createStoredProcedureCall( "sp_person_phones");
call.registerParameter(1, Long.class, ParameterMode.IN).bindValue(1L);
ProcedureParameter<Long> parameter = call.registerParameter( 1, Long.class, ParameterMode.IN );
call.setParameter( parameter, 1L );
call.registerParameter(2, Class.class, ParameterMode.REF_CURSOR);
Output output = call.getOutputs().getCurrent();

View File

@ -19,6 +19,8 @@ import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.loader.custom.NonUniqueDiscoveredSqlAliasException;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.RootEntityResultTransformer;
import org.hibernate.transform.Transformers;
import org.hibernate.type.LongType;
import org.hibernate.type.StringType;
@ -382,7 +384,7 @@ public class SQLTest extends BaseEntityManagerFunctionalTestCase {
"JOIN Person pr ON ph.person_id = pr.id" )
.addEntity("phone", Phone.class )
.addJoin( "pr", "phone.person")
.setResultTransformer( Criteria.ROOT_ENTITY )
.setResultTransformer( RootEntityResultTransformer.INSTANCE )
.list();
for(Person person : persons) {
@ -425,7 +427,7 @@ public class SQLTest extends BaseEntityManagerFunctionalTestCase {
"JOIN phone_call c ON c.phone_id = ph.id" )
.addEntity("phone", Phone.class )
.addJoin( "c", "phone.calls")
.setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY )
.setResultTransformer( DistinctRootEntityResultTransformer.INSTANCE)
.list();
for(Phone phone : phones) {

View File

@ -25,7 +25,6 @@ import org.hibernate.EntityNameResolver;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.MultiTenancyStrategy;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.NullPrecedence;
import org.hibernate.SessionEventListener;
import org.hibernate.SessionFactoryObserver;

View File

@ -9,7 +9,6 @@ package org.hibernate.boot.registry.selector.internal;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;

View File

@ -22,7 +22,6 @@ import javax.persistence.SqlResultSetMapping;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.NamedResultSetMappingDefinition;
import org.hibernate.cfg.BinderHelper;

View File

@ -7,11 +7,9 @@
package org.hibernate.metamodel.model.domain;
import org.hibernate.Incubating;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.metamodel.model.mapping.spi.Writeable;
import org.hibernate.query.Query;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**

View File

@ -12,7 +12,6 @@ import java.util.function.Consumer;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification;
import org.hibernate.procedure.spi.NamedCallableQueryMemento;
import org.hibernate.query.hql.SemanticQueryProducer;

View File

@ -9,7 +9,6 @@ package org.hibernate.envers.test.integration.basic;
import java.util.Map;
import org.hibernate.cfg.Environment;
import org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory;
import org.hibernate.testing.TestForIssue;

View File

@ -109,14 +109,15 @@ distributions {
// from parent.project( 'hibernate-entitymanager' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
// }
into( 'lib/spatial' ) {
from(
( parent.project( 'hibernate-spatial' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
+ parent.project( 'hibernate-spatial' ).configurations.runtime )
- parent.project( 'hibernate-core' ).configurations.runtime
- parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files
)
}
// todo (6.0) - add back spatial
// into( 'lib/spatial' ) {
// from(
// ( parent.project( 'hibernate-spatial' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }
// + parent.project( 'hibernate-spatial' ).configurations.runtime )
// - parent.project( 'hibernate-core' ).configurations.runtime
// - parent.project( 'hibernate-core' ).configurations.archives.allArtifacts.files
// )
// }
into( 'lib/jpa-metamodel-generator' ) {
from parent.project( 'hibernate-jpamodelgen' ).configurations.archives.allArtifacts.files.filter{ file -> !file.name.endsWith('-sources.jar') }

View File

@ -12,7 +12,8 @@ include 'hibernate-core'
include 'hibernate-entitymanager'
include 'hibernate-testing'
include 'hibernate-envers'
include 'hibernate-spatial'
// todo (6.0): re-enable hibernate-spatial
//include 'hibernate-spatial'
include 'hibernate-java8'