HHH-8126 migrate HEM to metamodel branch

This commit is contained in:
Strong Liu 2013-04-02 14:16:49 +08:00
parent 57001426bc
commit 65f204fb72
102 changed files with 971 additions and 524 deletions

View File

@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -181,4 +182,17 @@ public final class CollectionHelper {
copy.putAll( map );
return copy;
}
public static void cleanUpNullValue(Map map) {
if ( isEmpty( map ) ) {
return;
}
Iterator itr = map.entrySet().iterator();
while ( itr.hasNext() ) {
final Map.Entry entry = (Map.Entry) itr.next();
if ( entry.getValue() == null ) {
itr.remove();
}
}
}
}

View File

@ -40,7 +40,6 @@ import java.util.zip.ZipEntry;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.jboss.logging.Logger;
@ -75,7 +74,10 @@ import org.hibernate.service.ServiceRegistry;
*/
public class MetadataSources {
private static final Logger LOG = Logger.getLogger( MetadataSources.class );
/**
* temporary option
*/
public static final String USE_NEW_METADATA_MAPPINGS = "hibernate.test.new_metadata_mappings";
private final ServiceRegistry serviceRegistry;
private final JaxbMappingProcessor jaxbProcessor;
private final List<CacheRegionDefinition> externalCacheRegionDefinitions = new ArrayList<CacheRegionDefinition>();
@ -444,6 +446,7 @@ public class MetadataSources {
*/
public MetadataSources addDirectory(File dir) {
File[] files = dir.listFiles();
if ( files != null && files.length > 0 ) {
for ( File file : files ) {
if ( file.isDirectory() ) {
addDirectory( file );
@ -452,6 +455,7 @@ public class MetadataSources {
addFile( file );
}
}
}
return this;
}
@ -526,7 +530,7 @@ public class MetadataSources {
for ( Class<?> fieldType : ReflectHelper.getFieldTypes( clazz ) ) {
if ( !fieldType.isPrimitive() && fieldType != Object.class ) {
try {
Index fieldIndex = JandexHelper.indexForClass(
IndexView fieldIndex = JandexHelper.indexForClass(
serviceRegistry.getService( ClassLoaderService.class ),
fieldType );
if ( !fieldIndex.getAnnotations(

View File

@ -299,6 +299,7 @@ public class Binder {
entityHierarchyHelper.applyToAllEntityHierarchies( entityHierarchiesByRootEntityName.values(), rootExecutor, subExecutor );
}
private void bindEntityHierarchiesExcludingNonIdAttributeBindings() {
LocalBindingContextExecutor rootEntityCallback = new LocalBindingContextExecutor() {
@Override

View File

@ -24,6 +24,8 @@
package org.hibernate.metamodel.internal;
import java.io.Serializable;
import java.sql.Blob;
import java.sql.Clob;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -39,6 +41,7 @@ import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
import org.hibernate.annotations.common.util.StringHelper;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.CacheRegionDefinition;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.ObjectNameNormalizer;
@ -66,8 +69,10 @@ import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.MetadataSourceProcessor;
import org.hibernate.metamodel.spi.TypeContributions;
import org.hibernate.metamodel.spi.TypeContributor;
import org.hibernate.metamodel.spi.binding.AbstractPluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.BackRefAttributeBinding;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.FetchProfile;
import org.hibernate.metamodel.spi.binding.IdGenerator;
@ -249,7 +254,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
binder.addEntityHierarchies( processor.extractEntityHierarchies() );
binder.bindEntityHierarchies();
secondPass();
secondPass(metadataSources);
}
@ -271,7 +276,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
}
}
private void secondPass() {
private void secondPass(MetadataSources metadataSources) {
// This must be done outside of Table, rather than statically, to ensure
// deterministic alias names. See HHH-2448.
int uniqueInteger = 0;
@ -280,6 +285,44 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
table.setTableNumber( uniqueInteger++ );
}
}
if ( metadataSources.getExternalCacheRegionDefinitions().isEmpty() ) {
return;
}
for ( CacheRegionDefinition cacheRegionDefinition : metadataSources.getExternalCacheRegionDefinitions() ) {
final String role = cacheRegionDefinition.getRole();
if ( cacheRegionDefinition.getRegionType() == CacheRegionDefinition.CacheRegionType.ENTITY ) {
EntityBinding entityBinding = entityBindingMap.get( role );
if ( entityBinding != null ) {
entityBinding.getHierarchyDetails()
.setCaching(
new Caching(
cacheRegionDefinition.getRegion(),
AccessType.fromExternalName( cacheRegionDefinition.getUsage() ),
cacheRegionDefinition.isCacheLazy()
)
);
}else{
//logging?
throw new MappingException( "Can't find entitybinding for role " + role +" to apply cache configuration" );
}
}
else if ( cacheRegionDefinition.getRegionType() == CacheRegionDefinition.CacheRegionType.COLLECTION ) {
PluralAttributeBinding pluralAttributeBinding = collectionBindingMap.get( role );
if(pluralAttributeBinding!=null){
AbstractPluralAttributeBinding.class.cast( pluralAttributeBinding ).setCaching( new Caching(
cacheRegionDefinition.getRegion(),
AccessType.fromExternalName( cacheRegionDefinition.getUsage() ),
cacheRegionDefinition.isCacheLazy()
) );
} else {
//logging?
throw new MappingException( "Can't find entitybinding for role " + role +" to apply cache configuration" );
}
}
}
}
@Override

View File

@ -38,6 +38,7 @@ import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.hibernate.annotations.FetchMode;
@ -494,7 +495,7 @@ public class AssociationAttribute extends MappedAttribute {
// with the owning side.
if ( isJpaInverse ) {
// TODO: Pull some of this into JandexHelper.
Index index = JandexHelper.indexForClass(
IndexView index = JandexHelper.indexForClass(
getContext().getServiceRegistry().getService(
ClassLoaderService.class ), referencedAttributeType );
ClassInfo classInfo = index.getClassByName( DotName.createSimple(

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.Collection;
import java.util.HashMap;
import javax.persistence.LockModeType;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
@ -35,10 +36,14 @@ import org.jboss.jandex.AnnotationValue;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.MappingException;
import org.hibernate.annotations.CacheModeType;
import org.hibernate.annotations.FlushModeType;
import org.hibernate.annotations.QueryHints;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryRootReturn;
@ -46,6 +51,7 @@ import org.hibernate.engine.spi.NamedQueryDefinitionBuilder;
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.engine.spi.NamedSQLQueryDefinitionBuilder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.LockModeConverter;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
@ -135,13 +141,98 @@ public class QueryProcessor {
* @param annotation the named query annotation
*/
private static void bindNamedQuery(MetadataImplementor metadata, AnnotationInstance annotation) {
String name = JandexHelper.getValue( annotation, "name", String.class );
final String name = JandexHelper.getValue( annotation, "name", String.class );
if ( StringHelper.isEmpty( name ) ) {
throw new AnnotationException( "A named query must have a name when used in class or package level" );
}
NamedQueryDefinitionBuilder builder = new NamedQueryDefinitionBuilder();
builder.setName( name );
String query = JandexHelper.getValue( annotation, "query", String.class );
final String query = JandexHelper.getValue( annotation, "query", String.class );
builder.setQuery( query );
if ( annotation.name().equals( JPADotNames.NAMED_QUERY ) ) {
bindJPANamedQuery( annotation, builder, name, query );
} else {
builder.setFlushMode(
getFlushMode(
JandexHelper.getEnumValue(
annotation,
"flushMode",
FlushModeType.class
)
)
)
.setCacheable( JandexHelper.getValue( annotation, "cacheable", Boolean.class ) )
.setCacheRegion( JandexHelper.getValue( annotation, "cacheRegion", String.class ) )
.setFetchSize( JandexHelper.getValue( annotation, "fetchSize", Integer.class ) )
.setTimeout( JandexHelper.getValue( annotation, "timeout", Integer.class ) )
.setComment( JandexHelper.getValue( annotation, "comment", String.class ) )
.setCacheMode(
getCacheMode(
JandexHelper.getValue(
annotation,
"cacheMode",
CacheModeType.class
)
)
)
.setReadOnly( JandexHelper.getValue( annotation, "readOnly", Boolean.class ) );
}
metadata.addNamedQuery(builder.createNamedQueryDefinition());
LOG.debugf( "Binding named query: %s => %s", name, query );
}
public static FlushMode getFlushMode(FlushModeType flushModeType) {
FlushMode flushMode;
switch ( flushModeType ) {
case ALWAYS:
flushMode = FlushMode.ALWAYS;
break;
case AUTO:
flushMode = FlushMode.AUTO;
break;
case COMMIT:
flushMode = FlushMode.COMMIT;
break;
case NEVER:
flushMode = FlushMode.MANUAL;
break;
case MANUAL:
flushMode = FlushMode.MANUAL;
break;
case PERSISTENCE_CONTEXT:
flushMode = null;
break;
default:
throw new AssertionFailure( "Unknown flushModeType: " + flushModeType );
}
return flushMode;
}
private static CacheMode getCacheMode(CacheModeType cacheModeType) {
switch ( cacheModeType ) {
case GET:
return CacheMode.GET;
case IGNORE:
return CacheMode.IGNORE;
case NORMAL:
return CacheMode.NORMAL;
case PUT:
return CacheMode.PUT;
case REFRESH:
return CacheMode.REFRESH;
default:
throw new AssertionFailure( "Unknown cacheModeType: " + cacheModeType );
}
}
private static void bindJPANamedQuery(
AnnotationInstance annotation,
NamedQueryDefinitionBuilder builder,
String name,
String query){
AnnotationInstance[] hints = JandexHelper.getValue( annotation, "hints", AnnotationInstance[].class );
String cacheRegion = getString( hints, QueryHints.CACHE_REGION );
@ -159,6 +250,12 @@ public class QueryProcessor {
if ( lockTimeout != null && lockTimeout < 0 ) {
lockTimeout = null;
}
LockOptions lockOptions = new LockOptions( LockModeConverter.convertToLockMode( JandexHelper.getEnumValue( annotation, "lockMode",
LockModeType.class
) ) );
if ( lockTimeout != null ) {
lockOptions.setTimeOut( lockTimeout );
}
Integer fetchSize = getInteger( hints, QueryHints.FETCH_SIZE, name );
if ( fetchSize != null && fetchSize < 0 ) {
fetchSize = null;
@ -168,23 +265,16 @@ public class QueryProcessor {
if ( StringHelper.isEmpty( comment ) ) {
comment = null;
}
metadata.addNamedQuery(
new NamedQueryDefinitionBuilder()
.setName( name )
.setQuery( query )
.setCacheable( getBoolean( hints, QueryHints.CACHEABLE, name ) )
builder.setCacheable( getBoolean( hints, QueryHints.CACHEABLE, name ) )
.setCacheRegion( cacheRegion )
.setTimeout( timeout )
.setLockOptions( lockOptions )
.setFetchSize( fetchSize )
.setFlushMode( getFlushMode( hints, QueryHints.FLUSH_MODE, name ) )
.setCacheMode( getCacheMode( hints, QueryHints.CACHE_MODE, name ) )
.setReadOnly( getBoolean( hints, QueryHints.READ_ONLY, name ) )
.setComment( comment )
.setParameterTypes( null )
.createNamedQueryDefinition()
);
LOG.debugf( "Binding named query: %s => %s", name, query );
.setParameterTypes( null );
}
private static void bindNamedNativeQuery(MetadataImplementor metadata, AnnotationInstance annotation) {

View File

@ -120,14 +120,14 @@ public class SqlResultSetProcessor {
private static void bindEntityResult(final AnnotationBindingContext bindingContext,
final AnnotationInstance entityResult,
final ResultSetMappingDefinition definition) {
final Class entityClass = JandexHelper.getValue( entityResult, "entityClass", Class.class );
final String className = entityClass.getName();
// final Class entityClass = JandexHelper.getValue( entityResult, "entityClass", Class.class );
final String className = JandexHelper.getValue( entityResult, "entityClass", String.class );
//todo look up the whole entitybindings to find the right one seems stupid, but there is no way to look entitybinding
//by class name, since with hbm, hibernate actually supports map one class to multi entities.
final Iterable<EntityBinding> entityBindings = bindingContext.getMetadataImplementor().getEntityBindings();
EntityBinding targetEntityBinding = null;
for ( final EntityBinding entityBinding : entityBindings ) {
if ( className.equals( entityBinding.getEntity().getClass() ) ) {
if ( className.equals( entityBinding.getEntity().getClassName() ) ) {
targetEntityBinding = entityBinding;
break;
}

View File

@ -41,6 +41,7 @@ import org.jboss.jandex.MethodInfo;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.EntityHierarchyImpl;
@ -52,6 +53,7 @@ import org.hibernate.metamodel.internal.source.annotations.entity.RootEntityClas
import org.hibernate.metamodel.spi.binding.InheritanceType;
import org.hibernate.metamodel.spi.source.EntityHierarchy;
import org.hibernate.metamodel.spi.source.EntitySource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.SubclassEntitySource;
/**
@ -87,8 +89,7 @@ public class EntityHierarchyBuilder {
if ( processedEntities.contains( classInfo.name() ) ) {
continue;
}
ClassInfo rootClassInfo = findRootEntityClassInfo( index, classInfo );
ClassInfo rootClassInfo = findRootEntityClassInfo( index, classInfo, bindingContext );
List<ClassInfo> rootClassWithAllSubclasses = new ArrayList<ClassInfo>();
// collect the current root entity and all its subclasses
@ -181,7 +182,7 @@ public class EntityHierarchyBuilder {
*
* @return Finds the root entity starting at the entity given by {@code info}
*/
private static ClassInfo findRootEntityClassInfo(IndexView index, ClassInfo info) {
private static ClassInfo findRootEntityClassInfo(IndexView index, ClassInfo info, AnnotationBindingContext bindingContext) {
ClassInfo rootEntity = info;
DotName superName = info.superName();
@ -189,6 +190,20 @@ public class EntityHierarchyBuilder {
// walk up the hierarchy until java.lang.Object
while ( !OBJECT.equals( superName ) ) {
tmpInfo = index.getClassByName( superName );
if ( tmpInfo == null && superName != null ) {
Class clazz = bindingContext.locateClassByName( superName.toString() );
if ( clazz != null ) {
throw new AnnotationException(
info.name()
.toString() + "'s parent class [" + clazz.getName() + "] is not added into Jandex repository"
);
}else {
throw new AnnotationException(
info.name()
.toString() + "'s parent class [" + superName.toString() + "] doesn't exist in classpath"
);
}
}
if ( isEntityClass( tmpInfo ) ) {
rootEntity = tmpInfo;
}

View File

@ -43,6 +43,7 @@ import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.Type;
@ -304,7 +305,7 @@ public class JandexHelper {
*
* @return an annotation repository w/ all the annotation discovered in the specified classes
*/
public static Index indexForClass(ClassLoaderService classLoaderService, Class<?>... classes) {
public static IndexView indexForClass(ClassLoaderService classLoaderService, Class<?>... classes) {
Indexer indexer = new Indexer();
for ( Class<?> clazz : classes ) {
InputStream stream = classLoaderService.locateResourceStream(

View File

@ -39,6 +39,7 @@ import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
@ -221,16 +222,27 @@ public class IndexBuilder {
return serviceRegistry;
}
ClassInfo createClassInfo(String className) {
ClassInfo createClassInfo(String className, String optionalPerfix){
if ( StringHelper.isEmpty( className ) ) {
throw new AssertionFailure( "Class Name used to create ClassInfo is empty." );
}
Class clazz = null;
try {
clazz = serviceRegistry.getService( ClassLoaderService.class ).classForName( className );
}
catch ( ClassLoadingException e ) {
if ( StringHelper.isNotEmpty( optionalPerfix ) ) {
className = StringHelper.qualify( optionalPerfix, className );
clazz = serviceRegistry.getService( ClassLoaderService.class )
.classForName( className );
}
}
DotName classDotName = DotName.createSimple( className );
if ( classes.containsKey( classDotName ) ) {
//classInfoAnnotationsMap.put( classDotName, new HashMap<DotName, List<AnnotationInstance>>(classes.get( classDotName ).annotations()) );
return classes.get( classDotName );
}
Class clazz = serviceRegistry.getService( ClassLoaderService.class ).classForName( className );
DotName superName = null;
DotName[] interfaces = null;
short access_flag;
@ -265,6 +277,10 @@ public class IndexBuilder {
return classInfo;
}
ClassInfo createClassInfo(String className) {
return createClassInfo( className, null );
}
private void addSubClasses(DotName superClassDotName, ClassInfo classInfo) {
if ( superClassDotName != null ) {
List<ClassInfo> classInfoList = subclasses.get( superClassDotName );

View File

@ -33,6 +33,7 @@ import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.MappingException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.orm.JaxbEntityListener;
import org.hibernate.jaxb.spi.orm.JaxbEntityListeners;
@ -57,15 +58,20 @@ class ListenerMocker extends AbstractMocker {
List<String> clazzNameList = new ArrayList<String>( entityListeners.getEntityListener().size() );
for ( JaxbEntityListener listener : entityListeners.getEntityListener() ) {
MockHelper.addToCollectionIfNotNull( clazzNameList, listener.getClazz() );
parserEntityListener( listener );
parserEntityListener( listener, clazzNameList );
}
MockHelper.classArrayValue( "value", clazzNameList, annotationValueList, indexBuilder.getServiceRegistry() );
return create( ENTITY_LISTENERS, classInfo, annotationValueList );
}
private void parserEntityListener(JaxbEntityListener listener) {
private void parserEntityListener(JaxbEntityListener listener, List<String> clazzNameList) {
String clazz = listener.getClazz();
ClassInfo tempClassInfo = indexBuilder.createClassInfo( clazz );
String defaultPackageName = classInfo!=null ? StringHelper.qualifier(classInfo.name().toString()) : null;
ClassInfo tempClassInfo = indexBuilder.createClassInfo( clazz,defaultPackageName );
if ( !clazz.equals( tempClassInfo.name().toString() ) ) {
clazzNameList.remove( clazz );
clazzNameList.add( tempClassInfo.name().toString() );
}
ListenerMocker mocker = createListenerMocker( indexBuilder, tempClassInfo );
mocker.parser( listener.getPostLoad(), POST_LOAD );
mocker.parser( listener.getPostPersist(), POST_PERSIST );

View File

@ -392,9 +392,9 @@ public class MockHelper {
Method.setAccessible( methods, true );
for ( Method method : methods ) {
// if the method has parameters, skip it
if ( method.getParameterTypes().length != 0 ) {
continue;
}
// if ( method.getParameterTypes().length != 0 ) {
// continue;
// }
// if the method is a "bridge", skip it
if ( method.isBridge() ) {
continue;

View File

@ -134,7 +134,8 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
@Override
@SuppressWarnings( {"unchecked"})
public EntityPersister createEntityPersister(EntityBinding metadata,
public EntityPersister createEntityPersister(
EntityBinding metadata,
EntityRegionAccessStrategy cacheAccessStrategy,
NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
SessionFactoryImplementor factory,

View File

@ -35,6 +35,7 @@ import org.hibernate.event.service.spi.DuplicationStrategy;
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventType;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.ServiceContributingIntegrator;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.secure.internal.DisabledJaccServiceImpl;
import org.hibernate.secure.internal.JaccPreDeleteEventListener;
@ -51,7 +52,7 @@ import org.hibernate.service.spi.SessionFactoryServiceRegistry;
*
* @author Steve Ebersole
*/
public class JaccIntegrator implements ServiceContributor, Integrator {
public class JaccIntegrator implements ServiceContributingIntegrator {
private static final Logger log = Logger.getLogger( JaccIntegrator.class );
private static final DuplicationStrategy DUPLICATION_STRATEGY = new DuplicationStrategy() {
@ -69,7 +70,7 @@ public class JaccIntegrator implements ServiceContributor, Integrator {
@Override
public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) {
public void prepareServices(StandardServiceRegistryBuilder serviceRegistryBuilder) {
boolean isSecurityEnabled = serviceRegistryBuilder.getSettings().containsKey( AvailableSettings.JACC_ENABLED );
final JaccService jaccService = isSecurityEnabled ? new StandardJaccServiceImpl() : new DisabledJaccServiceImpl();
serviceRegistryBuilder.addService( JaccService.class, jaccService );

View File

@ -26,6 +26,7 @@ package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.Iterator;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -75,7 +76,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase {
})
class Foo {
}
Index index = JandexHelper.indexForClass( service, Foo.class );
IndexView index = JandexHelper.indexForClass( service, Foo.class );
FetchProfileProcessor.bind( new AnnotationBindingContextImpl( meta, index ) );
@ -90,7 +91,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase {
@Test
public void testFetchProfiles() {
Index index = JandexHelper.indexForClass( service, FooBar.class );
IndexView index = JandexHelper.indexForClass( service, FooBar.class );
FetchProfileProcessor.bind( new AnnotationBindingContextImpl( meta, index ) );
Iterator<org.hibernate.metamodel.spi.binding.FetchProfile> mappedFetchProfiles = meta.getFetchProfiles().iterator();
@ -126,7 +127,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase {
})
class Foo {
}
Index index = JandexHelper.indexForClass( service, Foo.class );
IndexView index = JandexHelper.indexForClass( service, Foo.class );
FetchProfileProcessor.bind( new AnnotationBindingContextImpl( meta, index ) );
}

View File

@ -26,6 +26,7 @@ package org.hibernate.metamodel.internal.source.annotations.global;
import javax.persistence.NamedNativeQuery;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -72,7 +73,7 @@ public class QueryBinderTest extends BaseUnitTestCase {
@NamedNativeQuery(name = "fubar", query = "SELECT * FROM FOO")
class Foo {
}
Index index = JandexHelper.indexForClass( service, Foo.class );
IndexView index = JandexHelper.indexForClass( service, Foo.class );
QueryProcessor.bind( new AnnotationBindingContextImpl( meta, index ) );
}
@ -81,7 +82,7 @@ public class QueryBinderTest extends BaseUnitTestCase {
@NamedNativeQuery(name = "fubar", query = "SELECT * FROM FOO", resultClass = Foo.class)
class Foo {
}
Index index = JandexHelper.indexForClass( service, Foo.class );
IndexView index = JandexHelper.indexForClass( service, Foo.class );
QueryProcessor.bind( new AnnotationBindingContextImpl( meta, index ) );
NamedSQLQueryDefinition namedQuery = meta.getNamedNativeQuery( "fubar" );

View File

@ -27,6 +27,7 @@ import java.util.Set;
import javax.persistence.AccessType;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.junit.After;
import org.junit.Before;
@ -58,7 +59,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
}
public Set<EntityHierarchy> createEntityHierarchies(Class<?>... clazz) {
Index index = JandexHelper.indexForClass(
IndexView index = JandexHelper.indexForClass(
meta.getServiceRegistry().getService( ClassLoaderService.class ),
clazz
);
@ -67,7 +68,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
}
public EmbeddableHierarchy createEmbeddableHierarchy(AccessType accessType,SingularAttributeBinding.NaturalIdMutability naturalIdMutability, Class<?>... configuredClasses) {
Index index = JandexHelper.indexForClass(
IndexView index = JandexHelper.indexForClass(
meta.getServiceRegistry().getService( ClassLoaderService.class ),
configuredClasses
);

View File

@ -23,6 +23,7 @@
*/
package org.hibernate.metamodel.internal.source.annotations.util;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.persistence.AttributeOverride;
@ -36,6 +37,7 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -81,7 +83,7 @@ public class JandexHelperTest extends BaseUnitTestCase {
private String bar;
private String fubar;
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
ClassInfo classInfo = index.getClassByName( DotName.createSimple( Foo.class.getName() ) );
Map<DotName, List<AnnotationInstance>> memberAnnotations = JandexHelper.getMemberAnnotations(
@ -106,10 +108,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.ATTRIBUTE_OVERRIDE );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.ATTRIBUTE_OVERRIDE );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
// try to retrieve the name
String name = JandexHelper.getValue( annotationInstance, "name", String.class );
@ -135,10 +137,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.ATTRIBUTE_OVERRIDE );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.ATTRIBUTE_OVERRIDE );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
JandexHelper.getValue( annotationInstance, "name", Float.class );
}
@ -149,10 +151,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.NAMED_QUERY );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.NAMED_QUERY );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
LockModeType lockMode = JandexHelper.getEnumValue( annotationInstance, "lockMode", LockModeType.class );
assertEquals( "Wrong lock mode", LockModeType.NONE, lockMode );
@ -164,10 +166,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.NAMED_QUERY );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.NAMED_QUERY );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
LockModeType lockMode = JandexHelper.getEnumValue( annotationInstance, "lockMode", LockModeType.class );
assertEquals( "Wrong lock mode", LockModeType.OPTIMISTIC, lockMode );
@ -180,10 +182,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
private String foo;
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.INDEX );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.INDEX );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
String[] columnNames = JandexHelper.getValue( annotationInstance, "columnNames", String[].class );
Assert.assertTrue( columnNames.length == 3 );
@ -195,10 +197,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.NAMED_NATIVE_QUERY );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.NAMED_NATIVE_QUERY );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
JandexHelper.getValue( annotationInstance, "resultClass", Class.class );
}
@ -209,10 +211,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.NAMED_NATIVE_QUERY );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( HibernateDotNames.NAMED_NATIVE_QUERY );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
String fqcn = JandexHelper.getValue( annotationInstance, "resultClass", String.class );
assertEquals( "Wrong class names", Foo.class.getName(), fqcn );
@ -224,10 +226,10 @@ public class JandexHelperTest extends BaseUnitTestCase {
class Foo {
}
Index index = JandexHelper.indexForClass( classLoaderService, Foo.class );
List<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.ENTITY );
IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class );
Collection<AnnotationInstance> annotationInstances = index.getAnnotations( JPADotNames.ENTITY );
assertTrue( annotationInstances.size() == 1 );
AnnotationInstance annotationInstance = annotationInstances.get( 0 );
AnnotationInstance annotationInstance = annotationInstances.iterator().next();
try {
JandexHelper.getValue( annotationInstance, "foo", String.class );

View File

@ -29,6 +29,7 @@ import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -37,6 +38,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class IdManyToOneTest extends BaseCoreFunctionalTestCase {
@Test
public void testFkCreationOrdering() throws Exception {

View File

@ -28,13 +28,11 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class ExplicitSqlResultSetMappingTest extends BaseCoreFunctionalTestCase {
private String queryString = null;

View File

@ -58,7 +58,7 @@ public class InsertedDataTest extends BaseCoreFunctionalTestCase {
}
@Override
protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
protected void prepareStandardServiceRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
serviceRegistryBuilder.applySetting( Environment.CACHE_REGION_PREFIX, "" );
serviceRegistryBuilder.applySetting( Environment.GENERATE_STATISTICS, "true" );
}

View File

@ -64,8 +64,8 @@ public class MergeCollectionEventTest extends BaseCoreFunctionalTestCase {
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder( builder );
protected void prepareBootstrapServiceRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapServiceRegistryBuilder( builder );
builder.with( collectionListenerIntegrator );
}

View File

@ -54,19 +54,14 @@ public class CallbackTest extends BaseCoreFunctionalTestCase {
private TestingObserver observer = new TestingObserver();
private TestingListener listener = new TestingListener();
@Override
public String[] getMappings() {
return NO_MAPPINGS;
}
@Override
public void configure(Configuration cfg) {
cfg.setSessionFactoryObserver( observer );
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder( builder );
protected void prepareBootstrapServiceRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapServiceRegistryBuilder( builder );
builder.with(
new Integrator() {

View File

@ -47,8 +47,8 @@ public class CommandExtractorServiceTest extends MultiLineImportFileTest {
}
@Override
protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
super.prepareBasicRegistryBuilder( serviceRegistryBuilder );
protected void prepareStandardServiceRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
super.prepareStandardServiceRegistryBuilder( serviceRegistryBuilder );
serviceRegistryBuilder.addService( ImportSqlCommandExtractor.class, new MultipleLinesSqlCommandExtractor() );
}
}

View File

@ -58,11 +58,6 @@ public class MultiLineImportFileTest extends BaseCoreFunctionalTestCase {
);
}
@Override
public String[] getMappings() {
return NO_MAPPINGS;
}
@Test
public void testImportFile() throws Exception {
Session s = openSession();

View File

@ -225,8 +225,8 @@ public class TestAutoFlushBeforeQueryExecution extends BaseCoreFunctionalTestCas
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder( builder );
protected void prepareBootstrapServiceRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapServiceRegistryBuilder( builder );
builder.with(
new Integrator() {

View File

@ -88,8 +88,8 @@ public class TestCollectionInitializingDuringFlush extends BaseCoreFunctionalTes
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder( builder );
protected void prepareBootstrapServiceRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapServiceRegistryBuilder( builder );
builder.with(
new Integrator() {

View File

@ -69,7 +69,7 @@ public abstract class AbstractJPATest extends BaseCoreFunctionalTestCase {
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
protected void prepareBootstrapServiceRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
builder.with(
new Integrator() {

View File

@ -62,8 +62,8 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
}
@Override
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapRegistryBuilder( builder );
protected void prepareBootstrapServiceRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
super.prepareBootstrapServiceRegistryBuilder( builder );
builder.with(
new Integrator() {

View File

@ -32,7 +32,6 @@ import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.stat.EntityStatistics;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;

View File

@ -30,7 +30,6 @@ import org.junit.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;

View File

@ -24,8 +24,6 @@
package org.hibernate.jpa;
import org.hibernate.internal.util.StringHelper;
/**
* Defines the available HEM settings, both JPA-defined as well as Hibernate-specific
* <p/>

View File

@ -23,6 +23,8 @@
*/
package org.hibernate.jpa.boot.internal;
import java.net.URL;
import org.hibernate.jpa.boot.spi.ClassDescriptor;
import org.hibernate.jpa.boot.spi.InputStreamAccess;
@ -38,6 +40,12 @@ public class ClassDescriptorImpl implements ClassDescriptor {
this.streamAccess = streamAccess;
}
public ClassDescriptorImpl(final Class clazz){
this.name = clazz.getName();
final URL url = clazz.getClassLoader().getResource( name.replace( '.', '/' ) + ".class" );
this.streamAccess = new UrlInputStreamAccess( url );
}
@Override
public String getName() {
return name;

View File

@ -40,7 +40,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -65,23 +64,26 @@ import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver;
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.internal.ConfigLoader;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.boot.spi.CacheRegionDefinition;
import org.hibernate.boot.spi.JaccDefinition;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping;
import org.hibernate.internal.util.ValueHolder;
@ -106,9 +108,12 @@ import org.hibernate.jpa.boot.scan.spi.ScanOptions;
import org.hibernate.jpa.boot.scan.spi.ScanResult;
import org.hibernate.jpa.boot.scan.spi.Scanner;
import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.Metadata;
import org.hibernate.metamodel.MetadataBuilder;
import org.hibernate.metamodel.SessionFactoryBuilder;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.spi.GrantedPermission;
import org.hibernate.secure.spi.JaccService;
@ -161,12 +166,16 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
private NamingStrategy namingStrategy;
private SessionFactoryObserver suppliedSessionFactoryObserver;
private MetadataSources metadataSources;
private MetadataSources mockMetadataSources;
private org.hibernate.metamodel.MetadataSources metadataSources;
private Configuration hibernateConfiguration;
private static EntityNotFoundDelegate jpaEntityNotFoundDelegate = new JpaEntityNotFoundDelegate();
private ClassLoader providedClassLoader;
private final IndexView jandexIndex;
private final boolean usingNewMetadata;
private static class JpaEntityNotFoundDelegate implements EntityNotFoundDelegate, Serializable {
public void handleEntityNotFound(String entityName, Serializable id) {
@ -204,16 +213,28 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
this.configurationValues = mergePropertySources( persistenceUnit, integrationSettings, bootstrapServiceRegistry );
// add all merged configuration values into the service registry builder
this.serviceRegistryBuilder.applySettings( configurationValues );
if ( configurationValues.containsKey( org.hibernate.metamodel.MetadataSources.USE_NEW_METADATA_MAPPINGS ) ) {
String value = (String)configurationValues.get( org.hibernate.metamodel.MetadataSources.USE_NEW_METADATA_MAPPINGS);
this.usingNewMetadata = Boolean.valueOf( value );
}
else {
this.usingNewMetadata = true;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Next we do a preliminary pass at metadata processing, which involves:
// 1) scanning
final ScanResult scanResult = scan( bootstrapServiceRegistry );
final DeploymentResources deploymentResources = buildDeploymentResources( scanResult, bootstrapServiceRegistry );
// 2) building a Jandex index
final IndexView jandexIndex = locateOrBuildJandexIndex( deploymentResources );
this.jandexIndex = locateOrBuildJandexIndex( deploymentResources );
// 3) building "metadata sources" to keep for later to use in building the SessionFactory
metadataSources = prepareMetadataSources( jandexIndex, deploymentResources, bootstrapServiceRegistry );
if ( usingNewMetadata ) {
metadataSources = prepareMetadataSources( deploymentResources, bootstrapServiceRegistry );
}
else {
mockMetadataSources = prepareMetadataSources( jandexIndex, deploymentResources );
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
withValidatorFactory( configurationValues.get( AvailableSettings.VALIDATION_FACTORY ) );
@ -223,7 +244,12 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// container situations, calling back into PersistenceUnitInfo#addClassTransformer
final boolean useClassTransformer = "true".equals( configurationValues.remove( AvailableSettings.USE_CLASS_ENHANCER ) );
if ( useClassTransformer ) {
persistenceUnit.pushClassTransformer( metadataSources.collectMappingClassNames() );
if ( !usingNewMetadata ) {
persistenceUnit.pushClassTransformer( mockMetadataSources.collectMappingClassNames() );
}
else {
throw new NotYetImplementedException( "The new JPA class enhancer is not supported in metamodel yet" );
}
}
}
@ -272,8 +298,28 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
final List<String> explicitClassNames = persistenceUnit.getManagedClassNames();
List<String> classNames = new ArrayList<String>();
if ( explicitClassNames != null ) {
for ( String explicitClassName : explicitClassNames ) {
classNames.addAll( explicitClassNames );
}
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping jaxbMapping : cfgXmlNamedMappings ) {
if ( jaxbMapping.getClazz() != null ) {
classNames.add( jaxbMapping.getClazz() );
}
else if ( jaxbMapping.getPackage() != null ) {
classNames.add( jaxbMapping.getPackage() );
}
}
List<Class> loadedAnnotatedClasses = (List<Class>) configurationValues.remove( AvailableSettings.LOADED_CLASSES );
if ( loadedAnnotatedClasses != null ) {
for ( Class cls : loadedAnnotatedClasses ) {
classNames.add( cls.getName() );
}
}
for ( String explicitClassName : classNames ) {
// IMPL NOTE : explicitClassNames can contain class or package names!!!
if ( classDescriptorMap.containsKey( explicitClassName ) ) {
continue;
@ -312,7 +358,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
persistenceUnit.getName()
);
}
}
return new DeploymentResources() {
@Override
@ -354,13 +400,45 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
return hibernateConfiguration;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private org.hibernate.metamodel.MetadataSources prepareMetadataSources(
DeploymentResources deploymentResources,
BootstrapServiceRegistry bootstrapServiceRegistry) {
org.hibernate.metamodel.MetadataSources ms = new org.hibernate.metamodel.MetadataSources(
bootstrapServiceRegistry
);
// for(ClassDescriptor classDescriptor : deploymentResources.getClassDescriptors()){
// final String className = classDescriptor.getName();
// ms.addAnnotatedClassName( className );
// }
//
// for ( PackageDescriptor packageDescriptor : deploymentResources.getPackageDescriptors() ) {
// ms.addPackage( packageDescriptor.getName() );
// }
for ( MappingFileDescriptor mappingFileDescriptor : deploymentResources.getMappingFileDescriptors() ) {
ms.addInputStream( mappingFileDescriptor.getStreamAccess().accessInputStream() );
}
final String explicitHbmXmls = (String) configurationValues.remove( AvailableSettings.HBXML_FILES );
if ( StringHelper.isNotEmpty( explicitHbmXmls ) ) {
for ( String fileName : StringHelper.split( ", ", explicitHbmXmls ) ) {
ms.addInputStream( bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream( fileName ));
}
}
final List<String> explicitOrmXml = (List<String>) configurationValues.remove( AvailableSettings.XML_FILE_NAMES );
if ( explicitOrmXml != null ) {
for ( String fileName : explicitOrmXml ) {
ms.addInputStream( bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream( fileName ));
}
}
return ms;
}
@SuppressWarnings("unchecked")
private MetadataSources prepareMetadataSources(
IndexView jandexIndex,
DeploymentResources deploymentResources,
BootstrapServiceRegistry bootstrapServiceRegistry) {
DeploymentResources deploymentResources) {
// todo : this needs to tie into the metamodel branch...
MetadataSources metadataSources = new MetadataSources();
@ -565,14 +643,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
// was getting NPE exceptions from the underlying map when just using #putAll, so going this safer route...
Iterator itr = merged.entrySet().iterator();
while ( itr.hasNext() ) {
final Map.Entry entry = (Map.Entry) itr.next();
if ( entry.getValue() == null ) {
itr.remove();
}
}
CollectionHelper.cleanUpNullValue( merged );
return merged;
}
@ -601,7 +672,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
= (JaxbHibernateConfiguration.JaxbSessionFactory.JaxbClassCache) cacheDeclaration;
cacheRegionDefinitions.add(
new CacheRegionDefinition(
CacheRegionDefinition.CacheType.ENTITY,
CacheRegionDefinition.CacheRegionType.ENTITY,
jaxbClassCache.getClazz(),
jaxbClassCache.getUsage().value(),
jaxbClassCache.getRegion(),
@ -614,7 +685,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
= (JaxbHibernateConfiguration.JaxbSessionFactory.JaxbCollectionCache) cacheDeclaration;
cacheRegionDefinitions.add(
new CacheRegionDefinition(
CacheRegionDefinition.CacheType.COLLECTION,
CacheRegionDefinition.CacheRegionType.COLLECTION,
jaxbCollectionCache.getCollection(),
jaxbCollectionCache.getUsage().value(),
jaxbCollectionCache.getRegion(),
@ -695,11 +766,11 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
}
private void addCacheRegionDefinition(String role, String value, CacheRegionDefinition.CacheType cacheType) {
private void addCacheRegionDefinition(String role, String value, CacheRegionDefinition.CacheRegionType cacheType) {
final StringTokenizer params = new StringTokenizer( value, ";, " );
if ( !params.hasMoreTokens() ) {
StringBuilder error = new StringBuilder( "Illegal usage of " );
if ( cacheType == CacheRegionDefinition.CacheType.ENTITY ) {
if ( cacheType == CacheRegionDefinition.CacheRegionType.ENTITY ) {
error.append( AvailableSettings.CLASS_CACHE_PREFIX )
.append( ": " )
.append( AvailableSettings.CLASS_CACHE_PREFIX );
@ -723,7 +794,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
region = params.nextToken();
}
boolean lazyProperty = true;
if ( cacheType == CacheRegionDefinition.CacheType.ENTITY ) {
if ( cacheType == CacheRegionDefinition.CacheRegionType.ENTITY ) {
if ( params.hasMoreTokens() ) {
lazyProperty = "all".equalsIgnoreCase( params.nextToken() );
}
@ -841,16 +912,84 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
@SuppressWarnings("unchecked")
@Override
public EntityManagerFactory build() {
processProperties();
final ServiceRegistry serviceRegistry = buildServiceRegistry();
final StandardServiceRegistry serviceRegistry = buildServiceRegistry();
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
// IMPL NOTE : TCCL handling here is temporary.
// It is needed because this code still uses Hibernate Configuration and Hibernate commons-annotations
// in turn which relies on TCCL being set.
if ( usingNewMetadata ) {
final JaccService jaccService = serviceRegistry.getService( JaccService.class );
for ( GrantedPermission grantedPermission : grantedJaccPermissions ) {
jaccService.addPermission( grantedPermission );
}
final Object strategyProviderValue = configurationValues.get( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
final IdentifierGeneratorStrategyProvider strategyProvider = strategyProviderValue == null
? null
: serviceRegistry.getService( StrategySelector.class )
.resolveStrategy( IdentifierGeneratorStrategyProvider.class, strategyProviderValue );
if ( strategyProvider != null ) {
for ( Map.Entry<String,Class<?>> entry : strategyProvider.getStrategies().entrySet() ) {
serviceRegistry.getService( MutableIdentifierGeneratorFactory.class ).register( entry.getKey(), entry.getValue() );
}
}
metadataSources.addCacheRegionDefinitions( cacheRegionDefinitions );
for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping jaxbMapping : cfgXmlNamedMappings ) {
if ( jaxbMapping.getResource() != null ) {
metadataSources.addResource( jaxbMapping.getResource() );
}
else if ( jaxbMapping.getJar() != null ) {
metadataSources.addJar( new File( jaxbMapping.getJar() ) );
}
}
MetadataBuilder builder = metadataSources.getMetadataBuilder( serviceRegistry );
builder.with( jandexIndex );
if ( namingStrategy != null ) {
builder.with( namingStrategy );
}
MetadataImplementor metadata = (MetadataImplementor)builder.build();
SessionFactoryBuilder sfBuilder = metadata.getSessionFactoryBuilder();
sfBuilder.with( jpaEntityNotFoundDelegate );
if ( sessionFactoryInterceptor != null ) {
sfBuilder.with( sessionFactoryInterceptor );
}
if ( suppliedSessionFactoryObserver != null ) {
sfBuilder.add( suppliedSessionFactoryObserver );
}
sfBuilder.add( new ServiceRegistryCloser() );
SessionFactoryImplementor sessionFactory;
try {
sessionFactory = (SessionFactoryImplementor) sfBuilder.build();
}
catch ( MappingException e ) {
throw persistenceException( "Unable to build Hibernate SessionFactory", e );
}
return new EntityManagerFactoryImpl(
persistenceUnit.getName(),
sessionFactory,
settings,
configurationValues,
serviceRegistry.getService( ConfigurationService.class ).getSettings()
);
}
else {
return ( (ClassLoaderServiceImpl) classLoaderService ).withTccl(
new ClassLoaderServiceImpl.Work<EntityManagerFactoryImpl>() {
@Override
@ -884,6 +1023,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
);
}
}
private void processProperties() {
applyJdbcConnectionProperties();
@ -932,14 +1072,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
addCacheRegionDefinition(
keyString.substring( AvailableSettings.CLASS_CACHE_PREFIX.length() + 1 ),
(String) entry.getValue(),
CacheRegionDefinition.CacheType.ENTITY
CacheRegionDefinition.CacheRegionType.ENTITY
);
}
else if ( keyString.startsWith( AvailableSettings.COLLECTION_CACHE_PREFIX ) ) {
addCacheRegionDefinition(
keyString.substring( AvailableSettings.COLLECTION_CACHE_PREFIX.length() + 1 ),
(String) entry.getValue(),
CacheRegionDefinition.CacheType.COLLECTION
CacheRegionDefinition.CacheRegionType.COLLECTION
);
}
else if ( keyString.startsWith( AvailableSettings.JACC_PREFIX )
@ -1018,7 +1158,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
: strategySelector.selectStrategyImplementor( Interceptor.class, value.toString() );
}
public ServiceRegistry buildServiceRegistry() {
public StandardServiceRegistry buildServiceRegistry() {
return serviceRegistryBuilder.build();
}
@ -1058,19 +1198,19 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
if ( cacheRegionDefinitions != null ) {
for ( CacheRegionDefinition cacheRegionDefinition : cacheRegionDefinitions ) {
if ( cacheRegionDefinition.cacheType == CacheRegionDefinition.CacheType.ENTITY ) {
if ( cacheRegionDefinition.getRegionType() == CacheRegionDefinition.CacheRegionType.ENTITY ) {
cfg.setCacheConcurrencyStrategy(
cacheRegionDefinition.role,
cacheRegionDefinition.usage,
cacheRegionDefinition.region,
cacheRegionDefinition.cacheLazy
cacheRegionDefinition.getRole(),
cacheRegionDefinition.getUsage(),
cacheRegionDefinition.getRegion(),
cacheRegionDefinition.isCacheLazy()
);
}
else {
cfg.setCollectionCacheConcurrencyStrategy(
cacheRegionDefinition.role,
cacheRegionDefinition.usage,
cacheRegionDefinition.region
cacheRegionDefinition.getRole(),
cacheRegionDefinition.getUsage(),
cacheRegionDefinition.getRegion()
);
}
}
@ -1080,34 +1220,19 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// todo : need to have this use the metamodel codebase eventually...
for ( JaxbMapping jaxbMapping : cfgXmlNamedMappings ) {
if ( jaxbMapping.getClazz() != null ) {
cfg.addAnnotatedClass(
serviceRegistry.getService( ClassLoaderService.class ).classForName( jaxbMapping.getClazz() )
);
}
else if ( jaxbMapping.getResource() != null ) {
if ( jaxbMapping.getResource() != null ) {
cfg.addResource( jaxbMapping.getResource() );
}
else if ( jaxbMapping.getJar() != null ) {
cfg.addJar( new File( jaxbMapping.getJar() ) );
}
else if ( jaxbMapping.getPackage() != null ) {
cfg.addPackage( jaxbMapping.getPackage() );
}
}
List<Class> loadedAnnotatedClasses = (List<Class>) configurationValues.remove( AvailableSettings.LOADED_CLASSES );
if ( loadedAnnotatedClasses != null ) {
for ( Class cls : loadedAnnotatedClasses ) {
cfg.addAnnotatedClass( cls );
}
}
for ( String className : metadataSources.getAnnotatedMappingClassNames() ) {
for ( String className : mockMetadataSources.getAnnotatedMappingClassNames() ) {
cfg.addAnnotatedClass( serviceRegistry.getService( ClassLoaderService.class ).classForName( className ) );
}
for ( MetadataSources.ConverterDescriptor converterDescriptor : metadataSources.getConverterDescriptors() ) {
for ( MetadataSources.ConverterDescriptor converterDescriptor : mockMetadataSources.getConverterDescriptors() ) {
final Class<? extends AttributeConverter> converterClass;
try {
Class theClass = serviceRegistry.getService( ClassLoaderService.class ).classForName( converterDescriptor.converterClassName );
@ -1124,7 +1249,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
cfg.addAttributeConverter( converterClass, converterDescriptor.autoApply );
}
for ( String resourceName : metadataSources.mappingFileResources ) {
for ( String resourceName : mockMetadataSources.mappingFileResources ) {
Boolean useMetaInf = null;
try {
if ( resourceName.endsWith( META_INF_ORM_XML ) ) {
@ -1152,7 +1277,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
LOG.exceptionHeaderNotFound( getExceptionHeader(), META_INF_ORM_XML );
}
}
for ( NamedInputStream namedInputStream : metadataSources.namedMappingFileInputStreams ) {
for ( NamedInputStream namedInputStream : mockMetadataSources.namedMappingFileInputStreams ) {
try {
//addInputStream has the responsibility to close the stream
cfg.addInputStream( new BufferedInputStream( namedInputStream.getStream() ) );
@ -1181,7 +1306,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
}
}
for ( String packageName : metadataSources.packageNames ) {
for ( String packageName : mockMetadataSources.packageNames ) {
cfg.addPackage( packageName );
}
return cfg;
@ -1217,41 +1342,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
return "[PersistenceUnit: " + persistenceUnit.getName() + "] ";
}
public static class CacheRegionDefinition {
public static enum CacheType { ENTITY, COLLECTION }
public final CacheType cacheType;
public final String role;
public final String usage;
public final String region;
public final boolean cacheLazy;
public CacheRegionDefinition(
CacheType cacheType,
String role,
String usage,
String region, boolean cacheLazy) {
this.cacheType = cacheType;
this.role = role;
this.usage = usage;
this.region = region;
this.cacheLazy = cacheLazy;
}
}
public static class JaccDefinition {
public final String contextId;
public final String role;
public final String clazz;
public final String actions;
public JaccDefinition(String contextId, String role, String clazz, String actions) {
this.contextId = contextId;
this.role = role;
this.clazz = clazz;
this.actions = actions;
}
}
public static class MetadataSources {
private final List<String> annotatedMappingClassNames = new ArrayList<String>();

View File

@ -46,6 +46,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.logging.Logger;
@ -121,6 +122,15 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
SettingsImpl settings,
Map<?, ?> configurationValues,
Configuration cfg) {
this(persistenceUnitName, sessionFactory, settings, configurationValues, cfg.getProperties() );
}
public EntityManagerFactoryImpl(
String persistenceUnitName,
SessionFactoryImplementor sessionFactory,
SettingsImpl settings,
Map configurationValues,
Map<?,?> cfg) {
this.sessionFactory = (SessionFactoryImpl) sessionFactory;
this.transactionType = settings.getTransactionType();
this.discardOnClose = settings.isReleaseResourcesOnCloseEnabled();
@ -131,7 +141,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
HashMap<String,Object> props = new HashMap<String, Object>();
addAll( props, sessionFactory.getProperties() );
addAll( props, cfg.getProperties() );
addAll( props, cfg );
addAll( props, configurationValues );
maskOutSensitiveInformation( props );
this.properties = Collections.unmodifiableMap( props );

View File

@ -8,11 +8,11 @@
<class>org.hibernate.jpa.test.pack.defaultpar.Lighter</class>
<validation-mode>CALLBACK</validation-mode>
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
</properties>

View File

@ -7,11 +7,11 @@
<persistence-unit name="defaultpar_1_0">
<class>org.hibernate.jpa.test.pack.defaultpar.Lighter</class>
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
</properties>

View File

@ -7,11 +7,11 @@
<persistence-unit name="excludehbmpar" transaction-type="RESOURCE_LOCAL">
<mapping-file>META-INF/orm2.xml</mapping-file>
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
<property name="hibernate.archive.autodetection" value="class"/>

View File

@ -14,11 +14,11 @@
<!-- custom scanner test -->
<property name="hibernate.ejb.resource_scanner" value="org.hibernate.jpa.test.packaging.CustomScanner"/>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.region_prefix" value="hibernate.test"/>
<property name="hibernate.jdbc.use_streams_for_binary" value="true"/>

View File

@ -6,11 +6,11 @@
version="2.0">
<persistence-unit name="explodedpar" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
</properties>

View File

@ -6,7 +6,6 @@
<persistence-unit name="overridenpar">
<jta-data-source>java:/unreachableDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
</properties>

View File

@ -1,4 +1,6 @@
hibernate.connection.driver_class @jdbc.driver@
hibernate.connection.url @jdbc.url@
hibernate.connection.username @jdbc.user@
hibernate.connection.password @jdbc.pass@
hibernate.connection.driver_class org.h2.Driver
hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
hibernate.connection.username sa
hibernate.connection.password

View File

@ -6,11 +6,11 @@
version="2.0">
<persistence-unit name="space par">
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
</properties>

View File

@ -7,11 +7,11 @@
<persistence-unit name="defaultpar">
<class>org.hibernate.jpa.test.pack.defaultpar.Lighter</class>
<properties>
<property name="hibernate.dialect" value="@db.dialect@"/>
<property name="hibernate.connection.driver_class" value="@jdbc.driver@"/>
<property name="hibernate.connection.username" value="@jdbc.user@"/>
<property name="hibernate.connection.password" value="@jdbc.pass@"/>
<property name="hibernate.connection.url" value="@jdbc.url@"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.testing.cache.CachingRegionFactory" />
</properties>

View File

@ -31,6 +31,7 @@ import javax.persistence.spi.PersistenceUnitTransactionType;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -40,7 +41,9 @@ import org.jboss.logging.Logger;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jpa.AvailableSettings;
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jpa.HibernatePersistenceProvider;
@ -51,6 +54,7 @@ import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
import org.hibernate.testing.junit4.BaseFunctionalTestCase;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
@ -59,23 +63,18 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCase {
public abstract class BaseEntityManagerFunctionalTestCase extends BaseFunctionalTestCase {
private static final Logger log = Logger.getLogger( BaseEntityManagerFunctionalTestCase.class );
// IMPL NOTE : Here we use @Before and @After (instead of @BeforeClassOnce and @AfterClassOnce like we do in
// BaseCoreFunctionalTestCase) because the old HEM test methodology was to create an EMF for each test method.
private static final Dialect dialect = Dialect.getDialect();
private StandardServiceRegistryImpl serviceRegistry;
private EntityManagerFactoryImpl entityManagerFactory;
private EntityManager em;
private ArrayList<EntityManager> isolatedEms = new ArrayList<EntityManager>();
protected Dialect getDialect() {
return dialect;
}
protected EntityManagerFactory entityManagerFactory() {
return entityManagerFactory;
@ -89,16 +88,16 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
@SuppressWarnings({ "UnusedDeclaration" })
public void buildEntityManagerFactory() throws Exception {
log.trace( "Building EntityManagerFactory" );
entityManagerFactory = (EntityManagerFactoryImpl) Bootstrap.getEntityManagerFactoryBuilder(
EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(
buildPersistenceUnitDescriptor(),
buildSettings()
).build();
);
entityManagerFactory = (EntityManagerFactoryImpl) entityManagerFactoryBuilder.build();
serviceRegistry = (StandardServiceRegistryImpl) entityManagerFactory.getSessionFactory()
.getServiceRegistry()
.getParentServiceRegistry();
configuration = entityManagerFactoryBuilder.getHibernateConfiguration();
afterEntityManagerFactoryBuilt();
}
@ -195,7 +194,9 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
@SuppressWarnings("unchecked")
protected Map buildSettings() {
Map settings = getConfig();
Map settings = Environment.getProperties();
addConfigOptions( settings );
addMappings( settings );
if ( createSchema() ) {
@ -209,67 +210,53 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
@SuppressWarnings("unchecked")
protected void addMappings(Map settings) {
String[] mappings = getMappings();
if ( mappings != null ) {
if ( mappings != null && mappings.length > 0 ) {
settings.put( AvailableSettings.HBXML_FILES, StringHelper.join( ",", mappings ) );
}
Class<?>[] annotatedClasses = getAnnotatedClasses();
if ( annotatedClasses != null && annotatedClasses.length > 0 ) {
List<Class<?>> classes = Arrays.asList( annotatedClasses );
settings.put( AvailableSettings.LOADED_CLASSES, classes );
}
protected static final String[] NO_MAPPINGS = new String[0];
protected String[] getMappings() {
return NO_MAPPINGS;
Map<Class, String> cachedClasses = getCachedClasses();
if ( CollectionHelper.isNotEmpty( cachedClasses ) ) {
for ( Map.Entry<Class, String> entry : cachedClasses.entrySet() ) {
settings.put( AvailableSettings.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(), entry.getValue() );
}
}
Map<String, String> cachedCollections = getCachedCollections();
if ( CollectionHelper.isNotEmpty( cachedCollections ) ) {
for ( Map.Entry<String, String> entry : cachedCollections.entrySet() ) {
settings.put( AvailableSettings.COLLECTION_CACHE_PREFIX + "." + entry.getKey(), entry.getValue() );
}
}
protected Map getConfig() {
Map<Object, Object> config = Environment.getProperties();
ArrayList<Class> classes = new ArrayList<Class>();
classes.addAll( Arrays.asList( getAnnotatedClasses() ) );
config.put( AvailableSettings.LOADED_CLASSES, classes );
for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
config.put( AvailableSettings.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(), entry.getValue() );
String[] dds = getEjb3DD();
if ( dds != null && dds.length > 0 ) {
List<String> list = Arrays.asList( dds );
settings.put( AvailableSettings.XML_FILE_NAMES, list );
}
for ( Map.Entry<String, String> entry : getCachedCollections().entrySet() ) {
config.put( AvailableSettings.COLLECTION_CACHE_PREFIX + "." + entry.getKey(), entry.getValue() );
}
if ( getEjb3DD().length > 0 ) {
ArrayList<String> dds = new ArrayList<String>();
dds.addAll( Arrays.asList( getEjb3DD() ) );
config.put( AvailableSettings.XML_FILE_NAMES, dds );
}
addConfigOptions( config );
return config;
}
protected void addConfigOptions(Map options) {
}
protected static final Class<?>[] NO_CLASSES = new Class[0];
protected Class<?>[] getAnnotatedClasses() {
return NO_CLASSES;
}
public Map<Class, String> getCachedClasses() {
return new HashMap<Class, String>();
return Collections.emptyMap();
}
public Map<String, String> getCachedCollections() {
return new HashMap<String, String>();
return Collections.emptyMap();
}
public String[] getEjb3DD() {
return new String[] { };
return NO_MAPPINGS;
}
protected void afterEntityManagerFactoryBuilt() {
}
protected boolean createSchema() {
return true;
}
@After
@SuppressWarnings( {"UnusedDeclaration"})

View File

@ -5,10 +5,12 @@ import javax.persistence.EntityManager;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class AssociationTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testBidirOneToOne() throws Exception {

View File

@ -125,6 +125,7 @@ public class ConfigurationTest extends BaseUnitTestCase {
private Configuration buildConfiguration(SharedCacheMode mode) {
Map settings = new HashMap();
settings.put( AvailableSettings.SHARED_CACHE_MODE, mode );
settings.put( org.hibernate.metamodel.MetadataSources.USE_NEW_METADATA_MAPPINGS, "false" );
settings.put( Environment.CACHE_REGION_FACTORY, CustomRegionFactory.class.getName() );
settings.put(
AvailableSettings.LOADED_CLASSES,

View File

@ -12,6 +12,7 @@ import org.hibernate.jpa.test.Cat;
import org.hibernate.jpa.test.Kitten;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -23,6 +24,7 @@ import static org.junit.Assert.fail;
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
@FailureExpectedWithNewMetamodel
public class CallbacksTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testCallbackMethod() throws Exception {

View File

@ -29,10 +29,12 @@ import javax.persistence.EntityTransaction;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Max Rydahl Andersen
*/
@FailureExpectedWithNewMetamodel
public class CascadeTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testCascade() throws Exception {

View File

@ -34,6 +34,7 @@ import org.junit.Test;
import org.hibernate.Hibernate;
import org.hibernate.ejb.HibernateEntityManager;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -41,6 +42,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class FetchTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testCascadeAndFetchCollection() throws Exception {

View File

@ -34,6 +34,7 @@ import org.junit.Test;
import org.hibernate.TransientPropertyValueException;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -175,6 +176,7 @@ public class MultiCircleJpaCascadeTest extends BaseEntityManagerFunctionalTestCa
}
@Test
@FailureExpectedWithNewMetamodel
public void testPersist() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
@ -186,6 +188,7 @@ public class MultiCircleJpaCascadeTest extends BaseEntityManagerFunctionalTestCa
}
@Test
@FailureExpectedWithNewMetamodel
public void testPersistNoCascadeToTransient() {
skipCleanup = true;
EntityManager em = getOrCreateEntityManager();
@ -326,7 +329,8 @@ public class MultiCircleJpaCascadeTest extends BaseEntityManagerFunctionalTestCa
D.class,
E.class,
F.class,
G.class
G.class,
AbstractEntity.class
};
}

View File

@ -29,12 +29,14 @@ import javax.persistence.EntityTransaction;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
@FailureExpectedWithNewMetamodel
public class MultiLevelCascadeTest extends BaseEntityManagerFunctionalTestCase {
@TestForIssue( jiraKey = "HHH-5299" )

View File

@ -39,11 +39,14 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class BasicCDITest extends BaseCDIIntegrationTest {
private static int count;

View File

@ -8,10 +8,12 @@ import java.util.Set;
import javax.persistence.EntityManager;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.junit.Test;
@TestForIssue( jiraKey="HHH-6043" )
@FailureExpectedWithNewMetamodel
public class PostLoadTest extends BaseEntityManagerFunctionalTestCase {
/**

View File

@ -40,6 +40,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.jpa.test.callbacks.CommunicationSystem;
import org.hibernate.jpa.test.metamodel.Address;
import org.hibernate.jpa.test.metamodel.Alias;
import org.hibernate.jpa.test.metamodel.Country;
@ -60,11 +61,13 @@ import org.hibernate.jpa.test.inheritance.Fruit;
import org.hibernate.jpa.test.inheritance.Strawberry;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.RequiresDialect;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class CriteriaCompilingTest extends BaseEntityManagerFunctionalTestCase {
@Override
public Class[] getAnnotatedClasses() {
@ -81,6 +84,7 @@ public class CriteriaCompilingTest extends BaseEntityManagerFunctionalTestCase {
Order.class,
Product.class,
ShelfLife.class,
CommunicationSystem.class,
// @Inheritance
Fruit.class,
Strawberry.class,

View File

@ -37,12 +37,14 @@ import org.hibernate.dialect.MySQLDialect;
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.jpa.test.metamodel.Customer;
import org.hibernate.jpa.test.metamodel.Customer_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
import org.junit.Test;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class ManipulationCriteriaTest extends AbstractMetamodelSpecificTest {
@Test
public void basicTest() {

View File

@ -33,6 +33,7 @@ import org.hibernate.jpa.test.metamodel.LineItem;
import org.hibernate.jpa.test.metamodel.LineItem_;
import org.hibernate.jpa.test.metamodel.Order;
import org.hibernate.jpa.test.metamodel.Order_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.junit.Test;
@ -41,6 +42,7 @@ import org.junit.Test;
*
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class OnKeywordTest extends AbstractMetamodelSpecificTest {
@Test
public void basicTest() {

View File

@ -33,10 +33,12 @@ import javax.persistence.criteria.Root;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class ParameterTest extends BaseEntityManagerFunctionalTestCase {
@Test

View File

@ -51,12 +51,14 @@ import org.hibernate.jpa.test.metamodel.Product;
import org.hibernate.jpa.test.metamodel.ShelfLife;
import org.hibernate.jpa.test.metamodel.Spouse;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
@Override
public Class[] getAnnotatedClasses() {

View File

@ -36,6 +36,7 @@ import org.hibernate.jpa.test.metamodel.Thing;
import org.hibernate.jpa.test.metamodel.ThingWithQuantity;
import org.hibernate.jpa.test.metamodel.ThingWithQuantity_;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.junit.Test;
@ -50,6 +51,7 @@ public class TreatKeywordTest extends BaseEntityManagerFunctionalTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void basicTest() {
EntityManager em = getOrCreateEntityManager();
CriteriaBuilder builder = em.getCriteriaBuilder();

View File

@ -38,10 +38,12 @@ import org.junit.Test;
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.jpa.test.metamodel.Product;
import org.hibernate.jpa.test.metamodel.Product_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class AggregationResultTest extends AbstractMetamodelSpecificTest {
private CriteriaBuilder builder;

View File

@ -38,8 +38,10 @@ import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.jpa.test.metamodel.Product;
import org.hibernate.jpa.test.metamodel.Product_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
@FailureExpectedWithNewMetamodel
public class CastTest extends AbstractMetamodelSpecificTest {
private static final int QUANTITY = 2;

View File

@ -46,6 +46,7 @@ import org.hibernate.jpa.test.metamodel.Phone;
import org.hibernate.jpa.test.metamodel.Product;
import org.hibernate.jpa.test.metamodel.Product_;
import org.hibernate.internal.AbstractQueryImpl;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
@ -56,6 +57,7 @@ import static org.junit.Assert.assertEquals;
*
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class ExpressionsTest extends AbstractMetamodelSpecificTest {
private CriteriaBuilder builder;

View File

@ -39,6 +39,7 @@ import org.hibernate.jpa.test.metamodel.Customer_;
import org.hibernate.jpa.test.metamodel.Order;
import org.hibernate.jpa.test.metamodel.Order_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertEquals;
@ -50,6 +51,7 @@ import static org.junit.Assert.assertTrue;
* @author Steve Ebersole
* @author Hardy Ferentschik
*/
@FailureExpectedWithNewMetamodel
public class PredicateTest extends AbstractMetamodelSpecificTest {
private CriteriaBuilder builder;

View File

@ -35,6 +35,7 @@ import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
/**
@ -43,7 +44,7 @@ import org.hibernate.testing.TestForIssue;
public class ComponentCriteriaTest extends BaseEntityManagerFunctionalTestCase {
@Override
public Class[] getAnnotatedClasses() {
return new Class[] { Client.class };
return new Class[] { Client.class, Name.class };
}
@Test
@ -86,6 +87,7 @@ public class ComponentCriteriaTest extends BaseEntityManagerFunctionalTestCase {
@Test
@TestForIssue( jiraKey = "HHH-4586" )
@FailureExpectedWithNewMetamodel
public void testParameterizedFunctions() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();

View File

@ -47,7 +47,9 @@ public class IdClassPredicateTest extends AbstractMetamodelSpecificTest {
public Class[] getAnnotatedClasses() {
return new Class[] {
Widget.class,
Tool.class
Tool.class,
Helper.class,
HelperId.class
};
}

View File

@ -36,6 +36,7 @@ import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.jpa.test.metamodel.Order;
import org.hibernate.jpa.test.metamodel.Thing;
import org.hibernate.jpa.test.metamodel.ThingWithQuantity;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
@ -43,6 +44,7 @@ import static org.junit.Assert.assertEquals;
* @author Michael Rudolf
* @author James Gilbertson
*/
@FailureExpectedWithNewMetamodel
public class AbstractPathImplTest extends AbstractMetamodelSpecificTest {
@Before
public void prepareTestData() {

View File

@ -37,10 +37,12 @@ import org.hibernate.jpa.test.metamodel.LineItem;
import org.hibernate.jpa.test.metamodel.LineItem_;
import org.hibernate.jpa.test.metamodel.Order;
import org.hibernate.jpa.test.metamodel.Order_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class ImplicitJoinTest extends AbstractMetamodelSpecificTest {
@Test
public void testImplicitJoinFromExplicitCollectionJoin() {

View File

@ -40,11 +40,13 @@ import org.hibernate.jpa.test.metamodel.LineItem;
import org.hibernate.jpa.test.metamodel.LineItem_;
import org.hibernate.jpa.test.metamodel.Order;
import org.hibernate.jpa.test.metamodel.Order_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class CorrelatedSubqueryTest extends AbstractMetamodelSpecificTest {
@Test
public void testBasicCorrelation() {

View File

@ -35,6 +35,7 @@ import org.hibernate.jpa.test.metamodel.Customer;
import org.hibernate.jpa.test.metamodel.Customer_;
import org.hibernate.jpa.test.metamodel.Order;
import org.hibernate.jpa.test.metamodel.Order_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.junit.Test;
@ -43,6 +44,7 @@ import static org.junit.Assert.fail;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class UncorrelatedSubqueryTest extends AbstractMetamodelSpecificTest {
@Test
public void testEqualAll() {

View File

@ -36,6 +36,7 @@ import org.junit.Test;
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
import org.hibernate.jpa.test.metamodel.Customer;
import org.hibernate.jpa.test.metamodel.Customer_;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -43,6 +44,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class TupleCriteriaTest extends AbstractMetamodelSpecificTest {
@Test
public void testArray() {

View File

@ -41,7 +41,9 @@ import org.hibernate.jpa.test.Cat;
import org.hibernate.jpa.test.Distributor;
import org.hibernate.jpa.test.Item;
import org.hibernate.jpa.test.Kitten;
import org.hibernate.jpa.test.LastUpdateListener;
import org.hibernate.jpa.test.Wallet;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -49,6 +51,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class EntityManagerFactorySerializationTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testSerialization() throws Exception {
@ -145,7 +148,8 @@ public class EntityManagerFactorySerializationTest extends BaseEntityManagerFunc
Distributor.class,
Wallet.class,
Cat.class,
Kitten.class
Kitten.class,
LastUpdateListener.class
};
}
}

View File

@ -42,11 +42,13 @@ import org.hibernate.jpa.test.Item;
import org.hibernate.jpa.test.Kitten;
import org.hibernate.jpa.test.NotSerializableClass;
import org.hibernate.jpa.test.Wallet;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Emmanuel Bernard
* @author Scott Marlow
*/
@FailureExpectedWithNewMetamodel
public class EntityManagerSerializationTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testSerialization() throws Exception {
@ -102,10 +104,8 @@ public class EntityManagerSerializationTest extends BaseEntityManagerFunctionalT
* @return
*/
@Override
protected Map getConfig() {
Map result = super.getConfig();
result.put( "BaseEntityManagerFunctionalTestCase.getConfig_addedNotSerializableObject", new NotSerializableClass());
return result;
protected void addConfigOptions(Map options) {
options.put( "BaseEntityManagerFunctionalTestCase.getConfig_addedNotSerializableObject", new NotSerializableClass());
}
@Override

View File

@ -54,6 +54,7 @@ import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.persister.collection.CollectionPersister;
@ -113,10 +114,10 @@ public class PersisterClassProviderTest {
return null;
}
}
@SuppressWarnings( {"UnusedParameters"})
public static class GoofyProvider implements EntityPersister {
@SuppressWarnings( {"UnusedParameters"})
public GoofyProvider(
org.hibernate.mapping.PersistentClass persistentClass,
org.hibernate.cache.spi.access.EntityRegionAccessStrategy strategy,
@ -126,6 +127,15 @@ public class PersisterClassProviderTest {
throw new GoofyException();
}
public GoofyProvider(
EntityBinding persistentClass,
org.hibernate.cache.spi.access.EntityRegionAccessStrategy strategy,
NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
SessionFactoryImplementor sf,
Mapping mapping) {
throw new GoofyException();
}
@Override
public EntityMode getEntityMode() {
return null;

View File

@ -30,6 +30,7 @@ import javax.persistence.EntityManager;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -37,6 +38,7 @@ import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class MergeTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testMergeWithIndexColumn() {

View File

@ -36,6 +36,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertEquals;
@ -46,6 +47,7 @@ import static org.junit.Assert.fail;
* @author Emmanuel Bernard
*/
@SuppressWarnings("unchecked")
@FailureExpectedWithNewMetamodel
public class ExceptionTest extends BaseEntityManagerFunctionalTestCase {
private static final Logger log = Logger.getLogger( ExceptionTest.class );

View File

@ -35,6 +35,7 @@ import javax.persistence.Subgraph;
import java.util.Set;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.junit.Test;
@ -61,6 +62,7 @@ public class BasicEntityGraphTests extends BaseEntityManagerFunctionalTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testBasicSubgraphBuilding() {
EntityManager em = getOrCreateEntityManager();
EntityGraph<Entity1> graphRoot = em.createEntityGraph( Entity1.class );
@ -80,6 +82,7 @@ public class BasicEntityGraphTests extends BaseEntityManagerFunctionalTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testBasicGraphImmutability() {
EntityManager em = getOrCreateEntityManager();
EntityGraph<Entity1> graphRoot = em.createEntityGraph( Entity1.class );

View File

@ -42,19 +42,27 @@ import org.junit.Test;
import org.hibernate.InvalidMappingException;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.jpa.test.pack.defaultpar.ApplicationServer;
import org.hibernate.jpa.test.pack.defaultpar.Lighter;
import org.hibernate.jpa.test.pack.defaultpar_1_0.ApplicationServer1;
import org.hibernate.jpa.test.pack.defaultpar_1_0.IncrementListener1;
import org.hibernate.jpa.test.pack.defaultpar_1_0.Lighter1;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
* "smoke" tests for JEE bootstrapping of HEM via a {@link PersistenceUnitInfo}
*
* @author Steve Ebersole
*/
public class OrmVersionTest {
@FailureExpectedWithNewMetamodel
public class OrmVersionTest extends BaseUnitTestCase{
@Test
public void testOrm1() {
PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl( "orm1-test", "1.0" )
.addMappingFileName( "org/hibernate/jpa/test/jee/valid-orm-1.xml" );
pui.getManagedClassNames().add( IncrementListener1.class.getName() );
pui.getManagedClassNames().add( ApplicationServer1.class.getName() );
HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
EntityManagerFactory emf = hp.createContainerEntityManagerFactory( pui, Collections.EMPTY_MAP );
emf.getMetamodel().entity( Lighter1.class ); // exception if not entity
@ -63,6 +71,8 @@ public class OrmVersionTest {
public void testOrm2() {
PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl( "orm2-test", "2.0" )
.addMappingFileName( "org/hibernate/jpa/test/jee/valid-orm-2.xml" );
pui.getManagedClassNames().add( org.hibernate.jpa.test.pack.defaultpar.IncrementListener.class.getName() );
pui.getManagedClassNames().add( ApplicationServer.class.getName() );
HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
EntityManagerFactory emf = hp.createContainerEntityManagerFactory( pui, Collections.EMPTY_MAP );
emf.getMetamodel().entity( Lighter.class ); // exception if not entity
@ -71,6 +81,8 @@ public class OrmVersionTest {
public void testInvalidOrm1() {
PersistenceUnitInfoImpl pui = new PersistenceUnitInfoImpl( "invalid-orm1-test", "1.0" )
.addMappingFileName( "org/hibernate/jpa/test/jee/invalid-orm-1.xml" );
pui.getManagedClassNames().add( IncrementListener1.class.getName() );
pui.getManagedClassNames().add( ApplicationServer1.class.getName() );
HibernatePersistenceProvider hp = new HibernatePersistenceProvider();
try {
hp.createContainerEntityManagerFactory( pui, Collections.EMPTY_MAP );

View File

@ -44,6 +44,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.jpa.metamodel.internal.legacy.MetamodelImpl;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -56,6 +57,7 @@ import static org.junit.Assert.fail;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class MetadataTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testBaseOfService() throws Exception {
@ -408,12 +410,15 @@ public class MetadataTest extends BaseEntityManagerFunctionalTestCase {
Dog.class,
Cat.class,
Cattish.class,
Animal.class,
Feline.class,
Garden.class,
Flower.class,
JoinedManyToOneOwner.class,
Parent.class,
Child.class
Child.class,
SubThing.class,
Thing.class
};
}

View File

@ -28,12 +28,14 @@ import javax.persistence.EntityManagerFactory;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertNotNull;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class SecondMetadataTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testBaseOfService() throws Exception {

View File

@ -33,6 +33,7 @@ import javax.persistence.metamodel.Type;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -42,6 +43,7 @@ import static org.junit.Assert.assertTrue;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class StaticMetadataTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testInjections() throws Exception {
@ -143,7 +145,11 @@ public class StaticMetadataTest extends BaseEntityManagerFunctionalTestCase {
Cattish.class,
Feline.class,
Garden.class,
Flower.class
Flower.class,
Animal.class,
SubThing.class,
Thing.class ,
Cattish.class
};
}
}

View File

@ -33,6 +33,7 @@ import org.hibernate.jpa.AvailableSettings;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -42,12 +43,13 @@ import static org.junit.Assert.assertNotNull;
* @author Steve Ebersole
*/
@TestForIssue( jiraKey = "HHH-5024" )
@FailureExpectedWithNewMetamodel(message = "jpa metamodel generation")
public class MappedSuperclassWithAttributesTest extends BaseUnitTestCase {
@Test
public void testStaticMetamodel() {
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(
AvailableSettings.LOADED_CLASSES,
Arrays.asList( Product.class )
Arrays.asList( Product.class,AbstractNameable.class )
);
assertNotNull( "'Product_.id' should not be null)", Product_.id );

View File

@ -31,6 +31,7 @@ import org.hibernate.jpa.AvailableSettings;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -39,13 +40,14 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel(message = "jpa metamodel generation")
public class MappedSuperclassWithEmbeddedTest extends BaseUnitTestCase {
@Test
@TestForIssue( jiraKey = "HHH-5024" )
public void testStaticMetamodel() {
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(
AvailableSettings.LOADED_CLASSES,
Arrays.asList( Company.class )
Arrays.asList( Company.class, AbstractAddressable.class, Address.class )
);
assertNotNull( "'Company_.id' should not be null)", Company_.id );

View File

@ -31,6 +31,7 @@ import org.hibernate.jpa.AvailableSettings;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -39,13 +40,14 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class MappedSuperclassWithEmbeddedIdTest extends BaseUnitTestCase {
@Test
@TestForIssue( jiraKey = "HHH-5024" )
public void testStaticMetamodel() {
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(
AvailableSettings.LOADED_CLASSES,
Arrays.asList( Product.class )
Arrays.asList( Product.class, AbstractProduct.class, ProductId.class )
);
assertNotNull( "'Product_.description' should not be null)", Product_.description );

View File

@ -31,6 +31,7 @@ import org.hibernate.jpa.AvailableSettings;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -40,13 +41,14 @@ import static org.junit.Assert.assertNotNull;
* @author Alexis Bataille
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class MappedSuperclassWithEntityWithIdClassTest extends BaseUnitTestCase {
@Test
@TestForIssue( jiraKey = "HHH-5024" )
public void testStaticMetamodel() {
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(
AvailableSettings.LOADED_CLASSES,
Arrays.asList( ProductAttribute.class )
Arrays.asList( ProductAttribute.class, AbstractAttribute.class )
);
assertNotNull( "'ProductAttribute_.value' should not be null)", ProductAttribute_.value );

View File

@ -29,6 +29,7 @@ import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertNotNull;
@ -36,10 +37,11 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class MappedSuperclassTypeTest extends BaseEntityManagerFunctionalTestCase {
@Override
public Class[] getAnnotatedClasses() {
return new Class[] { SomeMappedSuperclassSubclass.class };
return new Class[] { SomeMappedSuperclassSubclass.class, SomeMappedSuperclass.class };
}
@Test

View File

@ -61,6 +61,7 @@ import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventType;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.stat.Statistics;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -80,6 +81,7 @@ import static org.junit.Assert.fail;
@SuppressWarnings("unchecked")
public class PackagedEntityManagerTest extends PackagingTestCase {
@Test
@FailureExpectedWithNewMetamodel
public void testDefaultPar() throws Exception {
File testPackage = buildDefaultPar();
addPackageToClasspath( testPackage );
@ -115,6 +117,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testDefaultParForPersistence_1_0() throws Exception {
File testPackage = buildDefaultPar_1_0();
addPackageToClasspath( testPackage );
@ -149,6 +152,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testListenersDefaultPar() throws Exception {
File testPackage = buildDefaultPar();
addPackageToClasspath( testPackage );
@ -189,6 +193,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testExplodedPar() throws Exception {
File testPackage = buildExplodedPar();
addPackageToClasspath( testPackage );
@ -248,6 +253,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testCfgXmlPar() throws Exception {
File testPackage = buildCfgXmlPar();
addPackageToClasspath( testPackage );
@ -320,6 +326,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testListeners() throws Exception {
File testPackage = buildExplicitPar();
addPackageToClasspath( testPackage );
@ -340,6 +347,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testExtendedEntityManager() throws Exception {
File testPackage = buildExplicitPar();
addPackageToClasspath( testPackage );
@ -390,6 +398,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testConfiguration() throws Exception {
File testPackage = buildExplicitPar();
addPackageToClasspath( testPackage );
@ -443,6 +452,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testExternalJar() throws Exception {
File externalJar = buildExternalJar();
File testPackage = buildExplicitPar();
@ -468,6 +478,7 @@ public class PackagedEntityManagerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testORMFileOnMainAndExplicitJars() throws Exception {
File testPackage = buildExplicitPar();
addPackageToClasspath( testPackage );

View File

@ -93,6 +93,9 @@ public abstract class PackagingTestCase extends BaseCoreFunctionalTestCase {
} else {
// if running in some IDEs, may be in /bin instead
index = myUrl.getFile().lastIndexOf( "bin" );
if(index == -1){
index = myUrl.getFile().lastIndexOf( "out" );
}
}
if ( index == -1 ) {

View File

@ -42,6 +42,7 @@ import org.hibernate.jpa.boot.scan.spi.ScanResult;
import org.hibernate.jpa.boot.scan.spi.Scanner;
import org.hibernate.jpa.test.pack.defaultpar.ApplicationServer;
import org.hibernate.jpa.test.pack.defaultpar.Version;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.junit.Test;
@ -94,6 +95,7 @@ public class ScannerTest extends PackagingTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testCustomScanner() throws Exception {
File defaultPar = buildDefaultPar();
File explicitPar = buildExplicitPar();

View File

@ -40,6 +40,7 @@ import org.hibernate.jpa.test.Distributor;
import org.hibernate.jpa.test.Item;
import org.hibernate.jpa.test.Wallet;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertEquals;
@ -308,6 +309,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testNativeQueryByResultSet() {
Item item = new Item( "Mouse", "Micro$oft mouse" );
@ -581,6 +583,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testTypedNamedNativeQuery() {
Item item = new Item( "Mouse", "Micro$oft mouse" );

View File

@ -41,6 +41,7 @@ import org.hibernate.jpa.AvailableSettings;
import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
@ -119,6 +120,7 @@ public class SynchronizationTypeTest extends BaseEntityManagerFunctionalTestCase
}
@Test
@FailureExpectedWithNewMetamodel
public void testDisallowedOperations() throws Exception {
// test calling operations that are disallowed while a UNSYNCHRONIZED persistence context is not
// yet joined/enlisted

View File

@ -117,7 +117,9 @@ public class GetIdentifierTest extends BaseEntityManagerFunctionalTestCase {
public Class[] getAnnotatedClasses() {
return new Class[] {
Book.class,
CopyrightableContent.class,
Umbrella.class,
Umbrella.PK.class,
Sickness.class,
Author.class,
Article.class

View File

@ -28,6 +28,7 @@ import javax.persistence.EntityManager;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -37,6 +38,7 @@ import static org.junit.Assert.assertTrue;
*/
public class IsLoadedTest extends BaseEntityManagerFunctionalTestCase {
@Test
@FailureExpectedWithNewMetamodel
public void testIsLoadedOnPrivateSuperclassProperty() {
EntityManager em = entityManagerFactory().createEntityManager();
em.getTransaction().begin();

View File

@ -1,6 +1,7 @@
package org.hibernate.jpa.test.util;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@ -30,7 +31,7 @@ public class Umbrella {
public void setSize(int size) {
this.size = size;
}
@Embeddable
public static class PK implements Serializable {
private String model;
private String brand;

View File

@ -28,6 +28,7 @@ import javax.persistence.EntityManager;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals;
@ -55,6 +56,7 @@ public class XmlAttributeOverrideTest extends BaseEntityManagerFunctionalTestCas
}
@Test
@FailureExpectedWithNewMetamodel
public void testDefaultEventListener() throws Exception {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
@ -98,4 +100,9 @@ public class XmlAttributeOverrideTest extends BaseEntityManagerFunctionalTestCas
"org/hibernate/jpa/test/xml/orm3.xml"
};
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[]{CounterListener.class};
}
}

View File

@ -34,10 +34,12 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.jpa.AvailableSettings;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class XmlTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testXmlMappingCorrectness() throws Exception {
@ -53,11 +55,6 @@ public class XmlTest extends BaseEntityManagerFunctionalTestCase {
Assert.assertTrue(entityPersister.hasCache());
}
@Override
public Class[] getAnnotatedClasses() {
return new Class[0];
}
protected void addConfigOptions(Map options) {
options.put( AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE );
}
@ -69,4 +66,9 @@ public class XmlTest extends BaseEntityManagerFunctionalTestCase {
"org/hibernate/jpa/test/xml/orm2.xml",
};
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[]{Article.class};
}
}

View File

@ -29,13 +29,16 @@ import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.jpa.test.xml.*;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.RequiresDialectFeature;
/**
* @author Emmanuel Bernard
*/
@RequiresDialectFeature( DialectChecks.SupportsSequences.class )
@FailureExpectedWithNewMetamodel
public class XmlTest extends BaseEntityManagerFunctionalTestCase {
@Test
public void testXmlMappingCorrectness() throws Exception {
@ -50,4 +53,8 @@ public class XmlTest extends BaseEntityManagerFunctionalTestCase {
"org/hibernate/jpa/test/xml/sequences/orm2.xml",
};
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[]{ Article.class};
}
}

View File

@ -1,14 +1,9 @@
package org.hibernate.envers.test.integration.components;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import org.hibernate.Session;
import org.junit.Assert;
import org.junit.Test;
import org.hibernate.MappingException;
import org.hibernate.envers.test.BaseEnversFunctionalTestCase;
import org.hibernate.envers.test.Priority;
import org.hibernate.envers.test.entities.components.UniquePropsEntity;

View File

@ -31,7 +31,6 @@ import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import org.junit.Before;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.spi.RegionFactory;

View File

@ -18,15 +18,12 @@ import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import org.jboss.util.collection.ConcurrentSet;
import org.junit.After;
import org.junit.Test;
import javax.transaction.TransactionManager;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import static org.infinispan.test.TestingUtil.tmpDirectory;
import static org.infinispan.test.TestingUtil.withTx;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

Some files were not shown because too many files have changed in this diff Show More