Don't build session factory and entity manager eagerly and stop enforcing id class implements Serializable
This commit is contained in:
parent
f7d421b6ff
commit
ee52989647
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
@ -289,11 +288,6 @@ public class RootClass extends PersistentClass implements TableOwner {
|
|||
if ( !ReflectHelper.overridesHashCode( idClass ) ) {
|
||||
LOG.compositeIdClassDoesNotOverrideHashCode( idComponentClassName );
|
||||
}
|
||||
if ( !Serializable.class.isAssignableFrom( idClass ) ) {
|
||||
throw new MappingException(
|
||||
"Composite-id class must implement Serializable: " + idComponentClassName
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.metamodel.RuntimeMetamodels;
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
|
@ -39,6 +40,10 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
public class AttributeOrderingTests {
|
||||
@Test
|
||||
public void testOrdering(DomainModelScope modelScope, SessionFactoryScope sfScope) {
|
||||
// Force the creation of the session factory
|
||||
// We need this because properties are only sorted when finishing the initialization of the domain model
|
||||
SessionFactoryImplementor sessionFactory = sfScope.getSessionFactory();
|
||||
|
||||
// check the boot model.. it should have been sorted as part of calls to
|
||||
// prepare for mapping model creation
|
||||
|
||||
|
@ -47,7 +52,7 @@ public class AttributeOrderingTests {
|
|||
|
||||
// Also check the mapping model *and* the persister model - these need to be in-sync as far as ordering
|
||||
|
||||
final RuntimeMetamodels runtimeMetamodels = sfScope.getSessionFactory().getRuntimeMetamodels();
|
||||
final RuntimeMetamodels runtimeMetamodels = sessionFactory.getRuntimeMetamodels();
|
||||
verifyRuntimeEntityMapping( runtimeMetamodels.getEntityMappingType( TheEntity.class ) );
|
||||
verifyRuntimeEntityMapping( runtimeMetamodels.getEntityMappingType( "TheEntityHbm" ) );
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ dependencies {
|
|||
testCompile( "org.apache.karaf:apache-karaf:${project.karafVersion}" ) {
|
||||
// having trouble finding this one locally
|
||||
exclude group: 'org.eclipse', module: 'org.eclipse.osgi'
|
||||
exclude group: 'org.hibernate', module: 'hibernate-osgi'
|
||||
}
|
||||
|
||||
karafDistro "org.apache.karaf:apache-karaf:${project.karafVersion}@tar.gz"
|
||||
|
|
|
@ -289,8 +289,6 @@ public class EntityManagerFactoryExtension
|
|||
Map<String, Object> integrationSettings) {
|
||||
this.persistenceUnitInfo = persistenceUnitInfo;
|
||||
this.integrationSettings = integrationSettings;
|
||||
|
||||
this.emf = createEntityManagerFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,12 +132,16 @@ public class NotImplementedYetExtension
|
|||
final Boolean isStrict = (Boolean) store.get( IS_STRICT_STORE_KEY );
|
||||
|
||||
if ( isMarked ) {
|
||||
if ( throwable instanceof NotImplementedYetException || ! isStrict ) {
|
||||
store.put( EXCEPTION_STORE_KEY, throwable );
|
||||
Throwable t = throwable;
|
||||
do {
|
||||
if ( t instanceof NotImplementedYetException || ! isStrict ) {
|
||||
store.put( EXCEPTION_STORE_KEY, t );
|
||||
|
||||
log.debugf( "#Captured exception %s - ignoring it as expected", throwable );
|
||||
return;
|
||||
}
|
||||
log.debugf( "#Captured exception %s - ignoring it as expected", t );
|
||||
return;
|
||||
}
|
||||
t = t.getCause();
|
||||
} while ( t != null );
|
||||
}
|
||||
|
||||
// Otherwise, rethrow
|
||||
|
|
|
@ -236,8 +236,6 @@ public class SessionFactoryExtension
|
|||
SessionFactoryProducer producer) {
|
||||
this.modelScope = modelScope;
|
||||
this.producer = producer;
|
||||
|
||||
this.sessionFactory = createSessionFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue