diff --git a/build.gradle b/build.gradle
index a928e68648..d1ea36300f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -120,7 +120,6 @@ subprojects { subProject ->
testCompile files( toolsJar )
}
}
- ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt" )
sourceSets.main {
compileClasspath += configurations.provided
@@ -133,6 +132,7 @@ subprojects { subProject ->
}
task generateMainLoggingClasses(type: Compile) {
+ ext.aptDumpDir = subProject.file( "${buildDir}/tmp/apt/logging" )
classpath = compileJava.classpath + configurations.jbossLoggingTool
source = sourceSets.main.originalJavaSrcDirs
destinationDir = aptDumpDir
@@ -153,6 +153,9 @@ subprojects { subProject ->
doFirst {
sourceSets.main.generatedLoggingSrcDir.mkdirs()
}
+ doLast {
+ aptDumpDir.delete()
+ }
}
// for the time being eat the annoying output from running the annotation processors
diff --git a/changelog.txt b/changelog.txt
index 69d3f0de6d..5c577923da 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -256,7 +256,7 @@ https://hibernate.onjira.com/browse/HHH/fixforversion/11223
** Task
* [HHH-6082] - Incorporate EntityManager documentation into main dev guide
* [HHH-6336] - Add TenantIdentifierResolver
- * [HHH-6656] - Document org.hibernate.service.classloading.spi.ClassLoaderService
+ * [HHH-6656] - Document org.hibernate.boot.registry.classloading.spi.ClassLoaderService
* [HHH-6966] - Re apply HHH-6782
* [HHH-6985] - Change up tests for PostgreSQL LockMode issues
* [HHH-7011] - Document multi-tenancy
diff --git a/documentation/src/main/docbook/devguide/en-US/Database_Access.xml b/documentation/src/main/docbook/devguide/en-US/Database_Access.xml
index 8009f379a5..c0f764d976 100644
--- a/documentation/src/main/docbook/devguide/en-US/Database_Access.xml
+++ b/documentation/src/main/docbook/devguide/en-US/Database_Access.xml
@@ -32,9 +32,9 @@
Hibernate obtains JDBC connections as needed though the
- org.hibernate.service.jdbc.connections.spi.ConnectionProvider interface
+ ConnectionProvider interface
which is a service contract. Applications may also supply their own
- org.hibernate.service.jdbc.connections.spi.ConnectionProvider implementation
+ ConnectionProvider implementation
to define a custom approach for supplying connections to Hibernate (from a different connection pool
implementation, for example).
@@ -232,7 +232,7 @@
You can define your own plugin strategy for obtaining JDBC connections by implementing the interface
- org.hibernate.service.jdbc.connections.spi.ConnectionProvider and specifying your custom
+ ConnectionProvider and specifying your custom
implementation with the hibernate.connection.provider_class property.
@@ -386,22 +386,22 @@
Dialect resolution
- Assuming a org.hibernate.service.jdbc.connections.spi.ConnectionProvider has been
+ Assuming a ConnectionProvider has been
set up, Hibernate will attempt to automatically determine the Dialect to use based on the
java.sql.DatabaseMetaData reported by a
java.sql.Connection obtained from that
- org.hibernate.service.jdbc.connections.spi.ConnectionProvider .
+ ConnectionProvider .
This functionality is provided by a series of
- org.hibernate.service.jdbc.dialect.spi.DialectResolver instances registered
+ org.hibernate.engine.jdbc.dialect.spi.DialectResolver instances registered
with Hibernate internally. Hibernate comes with a standard set of recognitions. If your application
requires extra Dialect resolution capabilities, it would simply register a custom implementation
- of org.hibernate.service.jdbc.dialect.spi.DialectResolver as follows:
+ of org.hibernate.engine.jdbc.dialect.spi.DialectResolver as follows:
- Registered org.hibernate.service.jdbc.dialect.spi.DialectResolver are
+ Registered org.hibernate.engine.jdbc.dialect.spi.DialectResolver are
prepended to an internal list of resolvers, so they take precedence
before any already registered resolvers including the standard one.
diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml b/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml
index a5a2d0a805..b2432b96f2 100644
--- a/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml
+++ b/documentation/src/main/docbook/devguide/en-US/chapters/multitenancy/Multi_Tenancy.xml
@@ -149,7 +149,7 @@
Correlates to the separate schema approach. It is an error to attempt to open a session without
a tenant identifier using this strategy. Additionally, a
- org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider
+ MultiTenantConnectionProvider
must be specified.
@@ -160,7 +160,7 @@
Correlates to the separate database approach. It is an error to attempt to open a session without
a tenant identifier using this strategy. Additionally, a
- org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider
+ MultiTenantConnectionProvider
must be specified.
@@ -182,7 +182,7 @@
When using either the DATABASE or SCHEMA approach, Hibernate needs to be able to obtain Connections
in a tenant specific manner. That is the role of the
- org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider
+ MultiTenantConnectionProvider
contract. Application developers will need to provide an implementation of this
contract. Most of its methods are extremely self-explanatory. The only ones which might not be are
getAnyConnection and releaseAnyConnection . It is
@@ -205,7 +205,7 @@
- Passed directly to the org.hibernate.service.ServiceRegistryBuilder .
+ Passed directly to the org.hibernate.boot.registry.StandardServiceRegistryBuilder .
@@ -213,7 +213,7 @@
If none of the above options match, but the settings do specify a
hibernate.connection.datasource value, Hibernate will assume it should
use the specific
- org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl
+ DataSourceBasedMultiTenantConnectionProviderImpl
implementation which works on a number of pretty reasonable assumptions when running inside of
an app server and using one javax.sql.DataSource per tenant.
See its javadocs for more details.
diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml b/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml
index 9ec01f2b97..66441367bc 100644
--- a/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml
+++ b/documentation/src/main/docbook/devguide/en-US/chapters/services/Services.xml
@@ -81,7 +81,7 @@
same registry as well as any parent registries.
- Use org.hibernate.service.ServiceRegistryBuilder to build a
+ Use org.hibernate.boot.registry.StandardServiceRegistryBuilder to build a
org.hibernate.service.ServiceRegistry instance.
@@ -121,7 +121,7 @@
- org.hibernate.service.config.spi.ConfigurationService
+ org.hibernate.engine.config.spi.ConfigurationService
Notes
@@ -137,7 +137,7 @@
Initiator
- org.hibernate.service.config.internal.ConfigurationServiceInitiator
+ org.hibernate.engine.config.internal.ConfigurationServiceInitiator
@@ -145,7 +145,7 @@
Implementations
- org.hibernate.service.config.internal.ConfigurationServiceImpl
+ org.hibernate.engine.config.internal.ConfigurationServiceImpl
@@ -153,7 +153,7 @@
- org.hibernate.service.jdbc.connections.spi.ConnectionProvider
+ ConnectionProvider
Notes
@@ -168,7 +168,7 @@
Initiator
- org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator
+ ConnectionProviderInitiator
@@ -184,14 +184,14 @@
- org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl -
+ DatasourceConnectionProviderImpl -
provides connection managed delegated to a
javax.sql.DataSource
- org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl -
+ DriverManagerConnectionProviderImpl -
provides rudimentary connection pooling based on simple custom pool. Note intended
production use!
@@ -204,7 +204,7 @@
- org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl -
+ UserSuppliedConnectionProviderImpl -
Provides no connection support. Indicates the user will supply connections to Hibernate directly.
Not recommended for use.
@@ -216,7 +216,7 @@
- org.hibernate.service.jdbc.dialect.spi.DialectFactory
+ org.hibernate.engine.jdbc.dialect.spi.DialectFactory
Notes
@@ -233,7 +233,7 @@
Initiator
- org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator
+ org.hibernate.engine.jdbc.dialect.internal.DialectFactoryInitiator
@@ -241,7 +241,7 @@
Implementations
- org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl
+ org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl
@@ -249,7 +249,7 @@
- org.hibernate.service.jdbc.dialect.spi.DialectResolver
+ org.hibernate.engine.jdbc.dialect.spi.DialectResolver
Notes
@@ -261,8 +261,8 @@
The standard resolver implementation acts as a chain, delegating to a series of individual
resolvers. The standard Hibernate resolution behavior is contained in
- org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver .
- org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator
+ org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver .
+ org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator
also consults with the hibernate.dialect_resolvers setting for any
custom resolvers.
@@ -272,7 +272,7 @@
Initiator
- org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator
+ org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator
@@ -280,7 +280,7 @@
Implementations
- org.hibernate.service.jdbc.dialect.internal.DialectResolverSet
+ org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet
@@ -319,7 +319,7 @@
- org.hibernate.service.jmx.spi.JmxService
+ org.hibernate.jmx.spi.JmxService
Notes
@@ -333,7 +333,7 @@
Initiator
- org.hibernate.service.jmx.internal.JmxServiceInitiator
+ org.hibernate.jmx.internal.JmxServiceInitiator
@@ -343,13 +343,13 @@
- org.hibernate.service.jmx.internal.DisabledJmxServiceImpl -
+ org.hibernate.jmx.internal.DisabledJmxServiceImpl -
A no-op implementation when JMX functionality is disabled.
- org.hibernate.service.jmx.internal.JmxServiceImpl -
+ org.hibernate.jmx.internal.JmxServiceImpl -
Standard implementation of JMX handling
@@ -360,7 +360,7 @@
- org.hibernate.service.jndi.spi.JndiService
+ org.hibernate.engine.jndi.spi.JndiService
Notes
@@ -374,7 +374,7 @@
Initiator
- org.hibernate.service.jndi.internal.JndiServiceInitiator
+ org.hibernate.engine.jndi.internal.JndiServiceInitiator
@@ -382,7 +382,7 @@
Implementations
- org.hibernate.service.jndi.internal.JndiServiceImpl
+ org.hibernate.engine.jndi.internal.JndiServiceImpl
@@ -390,7 +390,7 @@
- org.hibernate.service.jta.platform.spi.JtaPlatform
+ org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform
Notes
@@ -404,15 +404,16 @@
Initiator
- org.hibernate.service.jta.platform.internal.JtaPlatformInitiator
+ org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator
- JtaPlatformInitiator provides mapping against the legacy,
- now-deprecated org.hibernate.transaction.TransactionManagerLookup
- names internally for the Hibernate-provided
+ As of 5.0 support has been completely removed for mapping against legacy
org.hibernate.transaction.TransactionManagerLookup
- implementations.
+ names and custom implementations. Applications implementing
+ org.hibernate.transaction.TransactionManagerLookup
+ or using the hibernate.transaction.manager_lookup_class setting
+ should update to use JtaPlatform.
@@ -423,104 +424,110 @@
- org.hibernate.service.jta.platform.internal.BitronixJtaPlatform -
- Integration with the Bitronix stand-alone transaction manager.
+ org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform -
+ Integration with the Bitronix stand-alone transaction manager. Can also be referenced
+ using the Bitronix configuration short name
- org.hibernate.service.jta.platform.internal.BorlandEnterpriseServerJtaPlatform -
- Integration with the transaction manager as deployed within a Borland Enterprise Server
+ org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform -
+ Integration with the transaction manager as deployed within a Borland Enterprise Server.
+ Can also be referenced using the Borland configuration short name
- org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform -
- Integration with the transaction manager as deployed within a JBoss Application Server
+ org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform -
+ Integration with the transaction manager as deployed within a JBoss Application Server.
+ Can also be referenced using the JBossAS configuration short name
- org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform -
- Integration with the JBoss Transactions stand-alone transaction manager
+ org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform -
+ Integration with the JBoss Transactions stand-alone transaction manager.
+ Can also be referenced using the JBossTS configuration short name
- org.hibernate.service.jta.platform.internal.JOTMJtaPlatform -
- Integration with the JOTM stand-alone transaction manager
+ org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform -
+ Integration with the JOTM stand-alone transaction manager. Can also be referenced
+ using the JOTM configuration short name
- org.hibernate.service.jta.platform.internal.JOnASJtaPlatform -
- Integration with the JOnAS transaction manager.
+ org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform -
+ Integration with the JOnAS transaction manager. Can also be referenced using the
+ JOnAS configuration short name
- org.hibernate.service.jta.platform.internal.JRun4JtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform -
Integration with the transaction manager as deployed in a JRun 4 application server.
+ Can also be referenced using the JRun4 configuration short name
- org.hibernate.service.jta.platform.internal.NoJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform -
No-op version when no JTA set up is configured
- org.hibernate.service.jta.platform.internal.OC4JJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform -
Integration with transaction manager as deployed in an OC4J (Oracle) application
+ Can also be referenced using the OC4J configuration short name
server.
- org.hibernate.service.jta.platform.internal.OrionJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform -
Integration with transaction manager as deployed in an Orion application server.
+ Can also be referenced using the Orion configuration short name
- org.hibernate.service.jta.platform.internal.ResinJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform -
Integration with transaction manager as deployed in a Resin application server.
+ Can also be referenced using the Resin configuration short name
- org.hibernate.service.jta.platform.internal.SunOneJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform -
Integration with transaction manager as deployed in a Sun ONE (7 and above)
- application server.
+ application server. Can also be referenced using the SunOne
+ configuration short name
- org.hibernate.service.jta.platform.internal.TransactionManagerLookupBridge -
- Provides a bridge to legacy (and deprecated)
- org.hibernate.transaction.TransactionManagerLookup
- implementations
-
-
-
-
- org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform -
Integration with transaction manager as deployed in a WebSphere Application Server
- (6 and above).
+ (6 and above). Can also be referenced using the WebSphereExtended
+ configuration short name
- org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform -
Integration with transaction manager as deployed in a WebSphere Application Server
- (4, 5.0 and 5.1).
+ (4, 5.0 and 5.1). Can also be referenced using the WebSphere
+ configuration short name
- org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform -
+ org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform -
Integration with transaction manager as deployed in a Weblogic application server.
+ Can also be referenced using the Weblogic configuration short name
@@ -530,7 +537,7 @@
- org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider
+ MultiTenantConnectionProvider
Notes
@@ -875,27 +882,27 @@
Once a org.hibernate.service.ServiceRegistry is built it is considered
immutable; the services themselves might accept re-configuration, but immutability here means
adding/replacing services. So another role provided by the
- org.hibernate.service.ServiceRegistryBuilder is to allow tweaking of the services
+ org.hibernate.boot.registry.StandardServiceRegistryBuilder is to allow tweaking of the services
that will be contained in the org.hibernate.service.ServiceRegistry
generated from it.
- There are 2 means to tell a org.hibernate.service.ServiceRegistryBuilder about
+ There are 2 means to tell a org.hibernate.boot.registry.StandardServiceRegistryBuilder about
custom services.
- Implement a org.hibernate.service.spi.BasicServiceInitiator class
+ Implement a org.hibernate.boot.registry.StandardServiceInitiator class
to control on-demand construction of the service class and add it to the
- org.hibernate.service.ServiceRegistryBuilder via its
+ org.hibernate.boot.registry.StandardServiceRegistryBuilder via its
addInitiator method.
Just instantiate the service class and add it to the
- org.hibernate.service.ServiceRegistryBuilder via its
+ org.hibernate.boot.registry.StandardServiceRegistryBuilder via its
addService method.
@@ -921,7 +928,7 @@
Instances of boot-strap registries are built using the
- org.hibernate.service.BootstrapServiceRegistryBuilder class.
+ org.hibernate.boot.registry.BootstrapServiceRegistryBuilder class.
@@ -932,7 +939,7 @@
Bootstrap registry services
- org.hibernate.service.classloading.spi.ClassLoaderService
+ org.hibernate.boot.registry.classloading.spi.ClassLoaderService
Hibernate needs to interact with ClassLoaders. However, the manner in which Hibernate
(or any library) should interact with ClassLoaders varies based on the runtime environment
@@ -986,7 +993,7 @@
This service focuses on the discovery aspect. It leverages the standard Java
java.util.ServiceLoader capability provided by the
- org.hibernate.service.classloading.spi.ClassLoaderService
+ org.hibernate.boot.registry.classloading.spi.ClassLoaderService
in order to discover implementations of the
org.hibernate.integrator.spi.Integrator contract.
Integrators would simply define a file named
diff --git a/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml b/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml
index 2aa3e844d1..9b282aa80b 100644
--- a/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml
+++ b/documentation/src/main/docbook/devguide/en-US/chapters/transactions/Transactions.xml
@@ -95,7 +95,7 @@
JTA-based transaction approach which leverages the
javax.transaction.UserTransaction interface as obtained from
- org.hibernate.service.jta.platform.spi.JtaPlatform API. This approach
+ org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform API. This approach
is represented by the
org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory class.
@@ -111,7 +111,7 @@
Another JTA-based transaction approach which leverages the JTA
javax.transaction.TransactionManager interface as obtained from
- org.hibernate.service.jta.platform.spi.JtaPlatform API. This approach
+ org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform API. This approach
is represented by the
org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory class. In
an actual JEE CMT environment, access to the
diff --git a/documentation/src/main/docbook/manual/en-US/content/architecture.xml b/documentation/src/main/docbook/manual/en-US/content/architecture.xml
index 4fb389482b..f9ad0e2e27 100644
--- a/documentation/src/main/docbook/manual/en-US/content/architecture.xml
+++ b/documentation/src/main/docbook/manual/en-US/content/architecture.xml
@@ -167,21 +167,6 @@
-
- JMX Integration
-
-
- JMX is the J2EE standard for the management of Java components. Hibernate can be managed via
- a JMX standard service. AN MBean implementation is provided in the distribution:
- org.hibernate.jmx.HibernateService .
-
-
-
- Another feature available as a JMX service is runtime Hibernate statistics. See
- for more information.
-
-
-
Contextual sessions
@@ -259,7 +244,7 @@
The hibernate.current_session_context_class configuration parameter
defines which org.hibernate.context.spi.CurrentSessionContext implementation
should be used. For backwards compatibility, if this configuration parameter is not set
- but a org.hibernate.transaction.TransactionManagerLookup is configured,
+ but a org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform is configured,
Hibernate will use the org.hibernate.context.internal.JTASessionContext .
Typically, the value of this parameter would just name the implementation class to
use. For the three out-of-the-box implementations, however, there are three corresponding
diff --git a/documentation/src/main/docbook/manual/en-US/content/configuration.xml b/documentation/src/main/docbook/manual/en-US/content/configuration.xml
index 7532bb94a3..7b40758ff5 100644
--- a/documentation/src/main/docbook/manual/en-US/content/configuration.xml
+++ b/documentation/src/main/docbook/manual/en-US/content/configuration.xml
@@ -1734,74 +1734,5 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQL82Dialect
transaction demarcation with CMT is preferred.
-
- JMX deployment
-
- The line cfg.buildSessionFactory() still has to
- be executed somewhere to get a SessionFactory into
- JNDI. You can do this either in a static initializer
- block, like the one in HibernateUtil , or you can
- deploy Hibernate as a managed service .
-
- Hibernate is distributed with
- org.hibernate.jmx.HibernateService for deployment on
- an application server with JMX capabilities, such as JBoss AS. The
- actual deployment and configuration is vendor-specific. Here is an
- example jboss-service.xml for JBoss 4.0.x:
-
- <?xml version="1.0"?>
-<server>
-
-<mbean code="org.hibernate.jmx.HibernateService"
- name="jboss.jca:service=HibernateFactory,name=HibernateFactory">
-
- <!-- Required services -->
- <depends>jboss.jca:service=RARDeployer</depends>
- <depends>jboss.jca:service=LocalTxCM,name=HsqlDS</depends>
-
- <!-- Bind the Hibernate service to JNDI -->
- <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
-
- <!-- Datasource settings -->
- <attribute name="Datasource">java:HsqlDS</attribute>
- <attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute>
-
- <!-- Transaction integration -->
- <attribute name="TransactionStrategy">
- org.hibernate.transaction.JTATransactionFactory</attribute>
- <attribute name="TransactionManagerLookupStrategy">
- org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
- <attribute name="FlushBeforeCompletionEnabled">true</attribute>
- <attribute name="AutoCloseSessionEnabled">true</attribute>
-
- <!-- Fetching options -->
- <attribute name="MaximumFetchDepth">5</attribute>
-
- <!-- Second-level caching -->
- <attribute name="SecondLevelCacheEnabled">true</attribute>
- <attribute name="CacheProviderClass">org.hibernate.cache.internal.EhCacheProvider</attribute>
- <attribute name="QueryCacheEnabled">true</attribute>
-
- <!-- Logging -->
- <attribute name="ShowSqlEnabled">true</attribute>
-
- <!-- Mapping files -->
- <attribute name="MapResources">auction/Item.hbm.xml,auction/Category.hbm.xml</attribute>
-
-</mbean>
-
-</server>
-
- This file is deployed in a directory called
- META-INF and packaged in a JAR file with the
- extension .sar (service archive). You also need to
- package Hibernate, its required third-party libraries, your compiled
- persistent classes, as well as your mapping files in the same archive.
- Your enterprise beans (usually session beans) can be kept in their own
- JAR file, but you can include this EJB JAR file in the main service
- archive to get a single (hot-)deployable unit. Consult the JBoss AS
- documentation for more information about JMX service and EJB
- deployment.
-
diff --git a/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml b/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml
index 0a551a950c..f10aa99caf 100644
--- a/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml
+++ b/documentation/src/main/docbook/quickstart/en-US/content/tutorial_annotations.xml
@@ -4,7 +4,7 @@
Tutorial Using Native Hibernate APIs and Annotation Mappings
- This tutorial is located within the download bundle under basic .
+ This tutorial is located within the download bundle under annotations .
Objectives
@@ -55,8 +55,7 @@ public class Event {
It functions the same as the class mapping element discussed in . Additionally the
@javax.persistence.Table annotation explicitly specifies the table
- name. Without this specification, the default table name would be EVENT ).
+ name. Without this specification, the default table name would be EVENT ).
diff --git a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java
index e9feac5f44..61238d83f5 100644
--- a/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java
+++ b/hibernate-c3p0/src/main/java/org/hibernate/service/jdbc/connections/internal/C3P0ConnectionProvider.java
@@ -35,11 +35,12 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
+import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java
index af61d3b84d..2175f15193 100644
--- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java
+++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java
@@ -32,7 +32,7 @@ import org.junit.Test;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
diff --git a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
index 2ae42ec8d7..9e527d2d6f 100644
--- a/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/SessionFactory.java
@@ -81,7 +81,7 @@ public interface SessionFactory extends Referenceable, Serializable {
* Open a {@link Session}.
*
* JDBC {@link Connection connection(s} will be obtained from the
- * configured {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} as needed
+ * configured {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} as needed
* to perform requested work.
*
* @return The created session.
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java
new file mode 100644
index 0000000000..d7d9387225
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistry.java
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry;
+
+import org.hibernate.service.ServiceRegistry;
+
+/**
+ * Specialization of the {@link org.hibernate.service.ServiceRegistry} contract mainly to make the
+ * {@link StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(BootstrapServiceRegistry)} signature type-safe
+ *
+ * @author Steve Ebersole
+ */
+public interface BootstrapServiceRegistry extends ServiceRegistry {
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java
new file mode 100644
index 0000000000..c8a97c0660
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java
@@ -0,0 +1,171 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry;
+
+import java.util.LinkedHashSet;
+
+import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
+import org.hibernate.boot.registry.selector.Availability;
+import org.hibernate.boot.registry.selector.AvailabilityAnnouncer;
+import org.hibernate.integrator.internal.IntegratorServiceImpl;
+import org.hibernate.integrator.spi.Integrator;
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
+import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder;
+
+/**
+ * Builder for bootstrap {@link org.hibernate.service.ServiceRegistry} instances.
+ *
+ * @author Steve Ebersole
+ *
+ * @see BootstrapServiceRegistryImpl
+ * @see StandardServiceRegistryBuilder#StandardServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistry)
+ */
+public class BootstrapServiceRegistryBuilder {
+ private final LinkedHashSet providedIntegrators = new LinkedHashSet();
+ private ClassLoader applicationClassLoader;
+ private ClassLoader resourcesClassLoader;
+ private ClassLoader hibernateClassLoader;
+ private ClassLoader environmentClassLoader;
+
+ private StrategySelectorBuilder strategySelectorBuilder = new StrategySelectorBuilder();
+
+ /**
+ * Add an {@link Integrator} to be applied to the bootstrap registry.
+ *
+ * @param integrator The integrator to add.
+ * @return {@code this}, for method chaining
+ */
+ public BootstrapServiceRegistryBuilder with(Integrator integrator) {
+ providedIntegrators.add( integrator );
+ return this;
+ }
+
+ /**
+ * Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry
+ *
+ * @param classLoader The class loader to use
+ * @return {@code this}, for method chaining
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) {
+ this.applicationClassLoader = classLoader;
+ return this;
+ }
+
+ /**
+ * Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry
+ *
+ * @param classLoader The class loader to use
+ * @return {@code this}, for method chaining
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) {
+ this.resourcesClassLoader = classLoader;
+ return this;
+ }
+
+ /**
+ * Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry
+ *
+ * @param classLoader The class loader to use
+ * @return {@code this}, for method chaining
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) {
+ this.hibernateClassLoader = classLoader;
+ return this;
+ }
+
+ /**
+ * Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry
+ *
+ * @param classLoader The class loader to use
+ * @return {@code this}, for method chaining
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) {
+ this.environmentClassLoader = classLoader;
+ return this;
+ }
+
+ /**
+ * Applies a named strategy implementation to the bootstrap registry
+ *
+ * @param strategy The strategy
+ * @param name The registered name
+ * @param implementation The strategy implementation Class
+ *
+ * @return {@code this}, for method chaining
+ *
+ * @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public BootstrapServiceRegistryBuilder withStrategySelector(Class strategy, String name, Class extends T> implementation) {
+ this.strategySelectorBuilder.addExplicitAvailability( strategy, implementation, name );
+ return this;
+ }
+
+ /**
+ * Applies one or more strategy selectors announced as available by the passed announcer.
+ *
+ * @param availabilityAnnouncer An announcer for one or more available selectors
+ *
+ * @return {@code this}, for method chaining
+ *
+ * @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public BootstrapServiceRegistryBuilder withStrategySelectors(AvailabilityAnnouncer availabilityAnnouncer) {
+ for ( Availability availability : availabilityAnnouncer.getAvailabilities() ) {
+ this.strategySelectorBuilder.addExplicitAvailability( availability );
+ }
+ return this;
+ }
+
+ /**
+ * Build the bootstrap registry.
+ *
+ * @return The built bootstrap registry
+ */
+ public BootstrapServiceRegistry build() {
+ final ClassLoaderServiceImpl classLoaderService = new ClassLoaderServiceImpl(
+ applicationClassLoader,
+ resourcesClassLoader,
+ hibernateClassLoader,
+ environmentClassLoader
+ );
+
+ final IntegratorServiceImpl integratorService = new IntegratorServiceImpl(
+ providedIntegrators,
+ classLoaderService
+ );
+
+
+ return new BootstrapServiceRegistryImpl(
+ classLoaderService,
+ strategySelectorBuilder.buildSelector( classLoaderService ),
+ integratorService
+ );
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/BasicServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java
similarity index 86%
rename from hibernate-core/src/main/java/org/hibernate/service/spi/BasicServiceInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java
index 1235549ff6..ceeb6cb1e6 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/spi/BasicServiceInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java
@@ -21,18 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.spi;
+package org.hibernate.boot.registry;
import java.util.Map;
import org.hibernate.service.Service;
+import org.hibernate.service.spi.ServiceInitiator;
+import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* Contract for an initiator of services that target the standard {@link org.hibernate.service.ServiceRegistry}
*
* @author Steve Ebersole
*/
-public interface BasicServiceInitiator extends ServiceInitiator {
+public interface StandardServiceInitiator extends ServiceInitiator {
/**
* Initiates the managed service.
*
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java
new file mode 100644
index 0000000000..04b50fdf82
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java
@@ -0,0 +1,224 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.hibernate.cfg.Environment;
+import org.hibernate.integrator.spi.Integrator;
+import org.hibernate.integrator.spi.IntegratorService;
+import org.hibernate.integrator.spi.ServiceContributingIntegrator;
+import org.hibernate.internal.util.config.ConfigurationHelper;
+import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
+import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
+import org.hibernate.service.ConfigLoader;
+import org.hibernate.service.Service;
+import org.hibernate.service.ServiceRegistry;
+import org.hibernate.service.StandardServiceInitiators;
+import org.hibernate.service.internal.ProvidedService;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
+
+/**
+ * Builder for standard {@link org.hibernate.service.ServiceRegistry} instances.
+ *
+ * @author Steve Ebersole
+ *
+ * @see StandardServiceRegistryImpl
+ * @see org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
+ */
+public class StandardServiceRegistryBuilder {
+ public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml";
+
+ private final Map settings;
+ private final List initiators = standardInitiatorList();
+ private final List providedServices = new ArrayList();
+
+ private final BootstrapServiceRegistry bootstrapServiceRegistry;
+ private final ConfigLoader configLoader;
+
+ /**
+ * Create a default builder
+ */
+ public StandardServiceRegistryBuilder() {
+ this( new BootstrapServiceRegistryImpl() );
+ }
+
+ /**
+ * Create a builder with the specified bootstrap services.
+ *
+ * @param bootstrapServiceRegistry Provided bootstrap registry to use.
+ */
+ public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry) {
+ this.settings = Environment.getProperties();
+ this.bootstrapServiceRegistry = bootstrapServiceRegistry;
+ this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
+ }
+
+ /**
+ * Used from the {@link #initiators} variable initializer
+ *
+ * @return List of standard initiators
+ */
+ private static List standardInitiatorList() {
+ final List initiators = new ArrayList();
+ initiators.addAll( StandardServiceInitiators.LIST );
+ return initiators;
+ }
+
+ /**
+ * Read settings from a {@link Properties} file. Differs from {@link #configure()} and {@link #configure(String)}
+ * in that here we read a {@link Properties} file while for {@link #configure} we read the XML variant.
+ *
+ * @param resourceName The name by which to perform a resource look up for the properties file.
+ *
+ * @return this, for method chaining
+ *
+ * @see #configure()
+ * @see #configure(String)
+ */
+ @SuppressWarnings( {"unchecked"})
+ public StandardServiceRegistryBuilder loadProperties(String resourceName) {
+ settings.putAll( configLoader.loadProperties( resourceName ) );
+ return this;
+ }
+
+ /**
+ * Read setting information from an XML file using the standard resource location
+ *
+ * @return this, for method chaining
+ *
+ * @see #DEFAULT_CFG_RESOURCE_NAME
+ * @see #configure(String)
+ * @see #loadProperties(String)
+ */
+ public StandardServiceRegistryBuilder configure() {
+ return configure( DEFAULT_CFG_RESOURCE_NAME );
+ }
+
+ /**
+ * Read setting information from an XML file using the named resource location
+ *
+ * @param resourceName The named resource
+ *
+ * @return this, for method chaining
+ *
+ * @see #loadProperties(String)
+ */
+ @SuppressWarnings( {"unchecked"})
+ public StandardServiceRegistryBuilder configure(String resourceName) {
+ JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName );
+ for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
+ settings.put( xmlProperty.getName(), xmlProperty.getValue() );
+ }
+
+ return this;
+ }
+
+ /**
+ * Apply a setting value
+ *
+ * @param settingName The name of the setting
+ * @param value The value to use.
+ *
+ * @return this, for method chaining
+ */
+ @SuppressWarnings( {"unchecked", "UnusedDeclaration"})
+ public StandardServiceRegistryBuilder applySetting(String settingName, Object value) {
+ settings.put( settingName, value );
+ return this;
+ }
+
+ /**
+ * Apply a groups of setting values
+ *
+ * @param settings The incoming settings to apply
+ *
+ * @return this, for method chaining
+ */
+ @SuppressWarnings( {"unchecked", "UnusedDeclaration"})
+ public StandardServiceRegistryBuilder applySettings(Map settings) {
+ this.settings.putAll( settings );
+ return this;
+ }
+
+ /**
+ * Adds a service initiator.
+ *
+ * @param initiator The initiator to be added
+ *
+ * @return this, for method chaining
+ */
+ @SuppressWarnings( {"UnusedDeclaration"})
+ public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
+ initiators.add( initiator );
+ return this;
+ }
+
+ /**
+ * Adds a user-provided service
+ *
+ * @param serviceRole The role of the service being added
+ * @param service The service implementation
+ *
+ * @return this, for method chaining
+ */
+ @SuppressWarnings( {"unchecked"})
+ public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
+ providedServices.add( new ProvidedService( serviceRole, service ) );
+ return this;
+ }
+
+ /**
+ * Build the service registry accounting for all settings and service initiators and services.
+ *
+ * @return The built service registry
+ */
+ public ServiceRegistry buildServiceRegistry() {
+ Map,?> settingsCopy = new HashMap();
+ settingsCopy.putAll( settings );
+ Environment.verifyProperties( settingsCopy );
+ ConfigurationHelper.resolvePlaceHolders( settingsCopy );
+
+ for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ).getIntegrators() ) {
+ if ( ServiceContributingIntegrator.class.isInstance( integrator ) ) {
+ ServiceContributingIntegrator.class.cast( integrator ).prepareServices( this );
+ }
+ }
+
+ return new StandardServiceRegistryImpl( bootstrapServiceRegistry, initiators, providedServices, settingsCopy );
+ }
+
+ /**
+ * Destroy a service registry. Applications should only destroy registries they have explicitly created.
+ *
+ * @param serviceRegistry The registry to be closed.
+ */
+ public static void destroy(ServiceRegistry serviceRegistry) {
+ ( (StandardServiceRegistryImpl) serviceRegistry ).destroy();
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/ClassLoaderServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/service/classloading/internal/ClassLoaderServiceImpl.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
index 3588970f17..6e152b459c 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/ClassLoaderServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.classloading.internal;
+package org.hibernate.boot.registry.classloading.internal;
import java.io.IOException;
import java.io.InputStream;
@@ -38,9 +38,8 @@ import java.util.ServiceLoader;
import org.jboss.logging.Logger;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
/**
* Standard implementation of the service for interacting with class loaders
@@ -54,8 +53,6 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
private final ClassLoader resourcesClassLoader;
private final ClassLoader serviceLoaderClassLoader;
- private final StrategyInstanceResolverImpl strategyInstanceResolver = new StrategyInstanceResolverImpl( this );
-
public ClassLoaderServiceImpl() {
this( ClassLoaderServiceImpl.class.getClassLoader() );
}
@@ -334,9 +331,4 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
}
}
-
- @Override
- public StrategyInstanceResolver getStrategyInstanceResolver() {
- return strategyInstanceResolver;
- }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoaderService.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoaderService.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java
index 9a2c37a72a..cc4cbe4d02 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoaderService.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoaderService.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.classloading.spi;
+package org.hibernate.boot.registry.classloading.spi;
import java.io.InputStream;
import java.net.URL;
@@ -86,11 +86,4 @@ public interface ClassLoaderService extends Service {
* @return The ordered set of discovered services.
*/
public LinkedHashSet loadJavaServices(Class serviceContract);
-
- /**
- * Retrieve a StrategyInstanceResolver instance. See StrategyInstanceResolver docs for details.
- *
- * @return The StrategyInstanceResolver instance.
- */
- public StrategyInstanceResolver getStrategyInstanceResolver();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoadingException.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoadingException.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java
index b7219ae444..ce02f02f99 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/ClassLoadingException.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/spi/ClassLoadingException.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.classloading.spi;
+package org.hibernate.boot.registry.classloading.spi;
import org.hibernate.HibernateException;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java
similarity index 71%
rename from hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java
index 5a33aeb1c6..2780846ea3 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/internal/BootstrapServiceRegistryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -21,18 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.internal;
+package org.hibernate.boot.registry.internal;
import java.util.LinkedHashSet;
import org.hibernate.integrator.internal.IntegratorServiceImpl;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
-import org.hibernate.service.BootstrapServiceRegistry;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.selector.internal.StrategySelectorImpl;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.service.spi.ServiceBinding;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceInitiator;
@@ -44,6 +46,11 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* {@link IntegratorService}
*
*
+ * IMPL NOTE : Currently implements the deprecated {@link org.hibernate.service.BootstrapServiceRegistry} contract
+ * so that the registry returned from the builder works on the deprecated sense. Once
+ * {@link org.hibernate.service.BootstrapServiceRegistry} goes away, this should be updated to instead implement
+ * {@link org.hibernate.boot.registry.BootstrapServiceRegistry}.
+ *
* @author Steve Ebersole
*/
public class BootstrapServiceRegistryImpl
@@ -51,6 +58,7 @@ public class BootstrapServiceRegistryImpl
private static final LinkedHashSet NO_INTEGRATORS = new LinkedHashSet();
private final ServiceBinding classLoaderServiceBinding;
+ private final ServiceBinding strategySelectorBinding;
private final ServiceBinding integratorServiceBinding;
public BootstrapServiceRegistryImpl() {
@@ -59,6 +67,30 @@ public class BootstrapServiceRegistryImpl
public BootstrapServiceRegistryImpl(
ClassLoaderService classLoaderService,
+ LinkedHashSet providedIntegrators) {
+ this.classLoaderServiceBinding = new ServiceBinding(
+ this,
+ ClassLoaderService.class,
+ classLoaderService
+ );
+
+ final StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
+ this.strategySelectorBinding = new ServiceBinding(
+ this,
+ StrategySelector.class,
+ strategySelector
+ );
+
+ this.integratorServiceBinding = new ServiceBinding(
+ this,
+ IntegratorService.class,
+ new IntegratorServiceImpl( providedIntegrators, classLoaderService )
+ );
+ }
+
+ public BootstrapServiceRegistryImpl(
+ ClassLoaderService classLoaderService,
+ StrategySelector strategySelector,
IntegratorService integratorService) {
this.classLoaderServiceBinding = new ServiceBinding(
this,
@@ -66,6 +98,12 @@ public class BootstrapServiceRegistryImpl
classLoaderService
);
+ this.strategySelectorBinding = new ServiceBinding(
+ this,
+ StrategySelector.class,
+ strategySelector
+ );
+
this.integratorServiceBinding = new ServiceBinding(
this,
IntegratorService.class,
@@ -74,13 +112,6 @@ public class BootstrapServiceRegistryImpl
}
- public BootstrapServiceRegistryImpl(
- ClassLoaderService classLoaderService,
- LinkedHashSet providedIntegrators) {
- this( classLoaderService, new IntegratorServiceImpl( providedIntegrators, classLoaderService ) );
- }
-
-
@Override
public R getService(Class serviceRole) {
@@ -94,6 +125,9 @@ public class BootstrapServiceRegistryImpl
if ( ClassLoaderService.class.equals( serviceRole ) ) {
return (ServiceBinding) classLoaderServiceBinding;
}
+ else if ( StrategySelector.class.equals( serviceRole) ) {
+ return (ServiceBinding) strategySelectorBinding;
+ }
else if ( IntegratorService.class.equals( serviceRole ) ) {
return (ServiceBinding) integratorServiceBinding;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/StandardServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java
similarity index 85%
rename from hibernate-core/src/main/java/org/hibernate/service/internal/StandardServiceRegistryImpl.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java
index f55423e977..23717955bc 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/internal/StandardServiceRegistryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java
@@ -21,15 +21,17 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.internal;
+package org.hibernate.boot.registry.internal;
import java.util.List;
import java.util.Map;
-import org.hibernate.service.BootstrapServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.service.internal.AbstractServiceRegistryImpl;
+import org.hibernate.service.internal.ProvidedService;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceBinding;
import org.hibernate.service.spi.ServiceInitiator;
@@ -45,7 +47,7 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
@SuppressWarnings( {"unchecked"})
public StandardServiceRegistryImpl(
BootstrapServiceRegistry bootstrapServiceRegistry,
- List serviceInitiators,
+ List serviceInitiators,
List providedServices,
Map, ?> configurationValues) {
super( bootstrapServiceRegistry );
@@ -66,7 +68,7 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp
@Override
public R initiateService(ServiceInitiator serviceInitiator) {
// todo : add check/error for unexpected initiator types?
- return ( (BasicServiceInitiator) serviceInitiator ).initiateService( configurationValues, this );
+ return ( (StandardServiceInitiator) serviceInitiator ).initiateService( configurationValues, this );
}
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java
new file mode 100644
index 0000000000..658bbb7bed
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/Availability.java
@@ -0,0 +1,33 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry.selector;
+
+/**
+ * @author Steve Ebersole
+ */
+public interface Availability {
+ public Class getStrategyRole();
+ public Iterable getSelectorNames();
+ public Class getStrategyImplementation();
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java
new file mode 100644
index 0000000000..eddc5b3e7e
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/AvailabilityAnnouncer.java
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry.selector;
+
+/**
+ * Responsible for announcing the availability of strategy selector(s). Can be registered directly with the
+ * {@link org.hibernate.boot.registry.BootstrapServiceRegistry} or located via discovery
+ *
+ * todo : better name?
+ *
+ * @author Steve Ebersole
+ */
+public interface AvailabilityAnnouncer {
+ public Iterable getAvailabilities();
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java
new file mode 100644
index 0000000000..ad515ce1ab
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/SimpleAvailabilityImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry.selector;
+
+import java.util.Arrays;
+
+/**
+ * @author Steve Ebersole
+ */
+public class SimpleAvailabilityImpl implements Availability {
+ private final Class strategyRole;
+ private final Class strategyImplementation;
+ private final Iterable selectorNames;
+
+ public SimpleAvailabilityImpl(
+ Class strategyRole,
+ Class strategyImplementation,
+ Iterable selectorNames) {
+ this.strategyRole = strategyRole;
+ this.strategyImplementation = strategyImplementation;
+ this.selectorNames = selectorNames;
+ }
+
+ public SimpleAvailabilityImpl(
+ Class strategyRole,
+ Class strategyImplementation,
+ String... selectorNames) {
+ this( strategyRole, strategyImplementation, Arrays.asList( selectorNames ) );
+ }
+
+ @Override
+ public Class getStrategyRole() {
+ return strategyRole;
+ }
+
+ @Override
+ public Iterable getSelectorNames() {
+ return selectorNames;
+ }
+
+ @Override
+ public Class getStrategyImplementation() {
+ return strategyImplementation;
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java
new file mode 100644
index 0000000000..6404478a06
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorBuilder.java
@@ -0,0 +1,330 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry.selector.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
+import org.hibernate.boot.registry.selector.Availability;
+import org.hibernate.boot.registry.selector.AvailabilityAnnouncer;
+import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl;
+import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
+import org.hibernate.dialect.CUBRIDDialect;
+import org.hibernate.dialect.Cache71Dialect;
+import org.hibernate.dialect.DB2390Dialect;
+import org.hibernate.dialect.DB2400Dialect;
+import org.hibernate.dialect.DB2Dialect;
+import org.hibernate.dialect.DerbyTenFiveDialect;
+import org.hibernate.dialect.DerbyTenSevenDialect;
+import org.hibernate.dialect.DerbyTenSixDialect;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.FirebirdDialect;
+import org.hibernate.dialect.FrontBaseDialect;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.dialect.InformixDialect;
+import org.hibernate.dialect.Ingres10Dialect;
+import org.hibernate.dialect.Ingres9Dialect;
+import org.hibernate.dialect.IngresDialect;
+import org.hibernate.dialect.InterbaseDialect;
+import org.hibernate.dialect.JDataStoreDialect;
+import org.hibernate.dialect.MckoiDialect;
+import org.hibernate.dialect.MimerSQLDialect;
+import org.hibernate.dialect.MySQL5Dialect;
+import org.hibernate.dialect.MySQL5InnoDBDialect;
+import org.hibernate.dialect.Oracle10gDialect;
+import org.hibernate.dialect.Oracle8iDialect;
+import org.hibernate.dialect.Oracle9iDialect;
+import org.hibernate.dialect.PointbaseDialect;
+import org.hibernate.dialect.PostgreSQL81Dialect;
+import org.hibernate.dialect.PostgreSQL82Dialect;
+import org.hibernate.dialect.PostgresPlusDialect;
+import org.hibernate.dialect.ProgressDialect;
+import org.hibernate.dialect.SAPDBDialect;
+import org.hibernate.dialect.SQLServer2005Dialect;
+import org.hibernate.dialect.SQLServer2008Dialect;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.dialect.Sybase11Dialect;
+import org.hibernate.dialect.SybaseASE157Dialect;
+import org.hibernate.dialect.SybaseASE15Dialect;
+import org.hibernate.dialect.SybaseAnywhereDialect;
+import org.hibernate.dialect.TeradataDialect;
+import org.hibernate.dialect.TimesTenDialect;
+import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
+import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
+import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
+import org.hibernate.engine.transaction.jta.platform.internal.BitronixJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.BorlandEnterpriseServerJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JOTMJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JOnASJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JRun4JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.OC4JJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.OrionJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.ResinJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.WebSphereJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.spi.TransactionFactory;
+
+/**
+ * @author Steve Ebersole
+ */
+public class StrategySelectorBuilder {
+ private static final Logger log = Logger.getLogger( StrategySelectorBuilder.class );
+
+ private final List explicitAvailabilities = new ArrayList();
+
+ @SuppressWarnings("unchecked")
+ public void addExplicitAvailability(Class strategy, Class extends T> implementation, String name) {
+ addExplicitAvailability( new SimpleAvailabilityImpl( strategy, implementation, name ) );
+ }
+
+ public void addExplicitAvailability(Availability availability) {
+ if ( !availability.getStrategyRole().isInterface() ) {
+ // not good form...
+ log.debug( "Registering non-interface strategy implementation : " + availability.getStrategyRole().getName() );
+ }
+
+ if ( ! availability.getStrategyRole().isAssignableFrom( availability.getStrategyImplementation() ) ) {
+ throw new StrategySelectionException(
+ "Implementation class [" + availability.getStrategyImplementation().getName()
+ + "] does not implement strategy interface ["
+ + availability.getStrategyRole().getName() + "]"
+ );
+ }
+ explicitAvailabilities.add( availability );
+ }
+
+ public StrategySelector buildSelector(ClassLoaderServiceImpl classLoaderService) {
+ StrategySelectorImpl strategySelector = new StrategySelectorImpl( classLoaderService );
+
+ // build the baseline...
+ addDialects( strategySelector );
+ addJtaPlatforms( strategySelector );
+ addTransactionFactories( strategySelector );
+
+ // apply auto-discovered registrations
+ for ( AvailabilityAnnouncer announcer : classLoaderService.loadJavaServices( AvailabilityAnnouncer.class ) ) {
+ for ( Availability discoveredAvailability : announcer.getAvailabilities() ) {
+ applyFromAvailability( strategySelector, discoveredAvailability );
+ }
+ }
+
+ // apply customizations
+ for ( Availability explicitAvailability : explicitAvailabilities ) {
+ applyFromAvailability( strategySelector, explicitAvailability );
+ }
+
+ return strategySelector;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void applyFromAvailability(StrategySelectorImpl strategySelector, Availability availability) {
+ for ( String name : availability.getSelectorNames() ) {
+ strategySelector.registerStrategyImplementor(
+ availability.getStrategyRole(),
+ name,
+ availability.getStrategyImplementation()
+ );
+ }
+ }
+
+ private void addDialects(StrategySelectorImpl strategySelector) {
+ addDialect( strategySelector, Cache71Dialect.class );
+ addDialect( strategySelector, CUBRIDDialect.class );
+ addDialect( strategySelector, DB2Dialect.class );
+ addDialect( strategySelector, DB2390Dialect.class );
+ addDialect( strategySelector, DB2400Dialect.class );
+ addDialect( strategySelector, DerbyTenFiveDialect.class );
+ addDialect( strategySelector, DerbyTenSixDialect.class );
+ addDialect( strategySelector, DerbyTenSevenDialect.class );
+ addDialect( strategySelector, FirebirdDialect.class );
+ addDialect( strategySelector, FrontBaseDialect.class );
+ addDialect( strategySelector, H2Dialect.class );
+ addDialect( strategySelector, HSQLDialect.class );
+ addDialect( strategySelector, InformixDialect.class );
+ addDialect( strategySelector, IngresDialect.class );
+ addDialect( strategySelector, Ingres9Dialect.class );
+ addDialect( strategySelector, Ingres10Dialect.class );
+ addDialect( strategySelector, InterbaseDialect.class );
+ addDialect( strategySelector, JDataStoreDialect.class );
+ addDialect( strategySelector, MckoiDialect.class );
+ addDialect( strategySelector, MimerSQLDialect.class );
+ addDialect( strategySelector, MySQL5Dialect.class );
+ addDialect( strategySelector, MySQL5InnoDBDialect.class );
+ addDialect( strategySelector, MySQL5Dialect.class );
+ addDialect( strategySelector, MySQL5InnoDBDialect.class );
+ addDialect( strategySelector, Oracle8iDialect.class );
+ addDialect( strategySelector, Oracle9iDialect.class );
+ addDialect( strategySelector, Oracle10gDialect.class );
+ addDialect( strategySelector, PointbaseDialect.class );
+ addDialect( strategySelector, PostgresPlusDialect.class );
+ addDialect( strategySelector, PostgreSQL81Dialect.class );
+ addDialect( strategySelector, PostgreSQL82Dialect.class );
+ addDialect( strategySelector, ProgressDialect.class );
+ addDialect( strategySelector, SAPDBDialect.class );
+ addDialect( strategySelector, SQLServerDialect.class );
+ addDialect( strategySelector, SQLServer2005Dialect.class );
+ addDialect( strategySelector, SQLServer2008Dialect.class );
+ addDialect( strategySelector, Sybase11Dialect.class );
+ addDialect( strategySelector, SybaseAnywhereDialect.class );
+ addDialect( strategySelector, SybaseASE15Dialect.class );
+ addDialect( strategySelector, SybaseASE157Dialect.class );
+ addDialect( strategySelector, TeradataDialect.class );
+ addDialect( strategySelector, TimesTenDialect.class );
+ }
+
+ private void addDialect(StrategySelectorImpl strategySelector, Class extends Dialect> dialectClass) {
+ String simpleName = dialectClass.getSimpleName();
+ if ( simpleName.endsWith( "Dialect" ) ) {
+ simpleName = simpleName.substring( 0, simpleName.length() - "Dialect".length() );
+ }
+ strategySelector.registerStrategyImplementor( Dialect.class, simpleName, dialectClass );
+ }
+
+ private void addJtaPlatforms(StrategySelectorImpl strategySelector) {
+ addJtaPlatforms(
+ strategySelector,
+ BorlandEnterpriseServerJtaPlatform.class,
+ "Borland",
+ "org.hibernate.service.jta.platform.internal.BorlandEnterpriseServerJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ BitronixJtaPlatform.class,
+ "Bitronix",
+ "org.hibernate.service.jta.platform.internal.BitronixJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ JBossAppServerJtaPlatform.class,
+ "JBossAS",
+ "org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ JBossStandAloneJtaPlatform.class,
+ "JBossTS",
+ "org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ JOnASJtaPlatform.class,
+ "JOnAS",
+ "org.hibernate.service.jta.platform.internal.JOnASJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ JOTMJtaPlatform.class,
+ "JOTM",
+ "org.hibernate.service.jta.platform.internal.JOTMJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ JRun4JtaPlatform.class,
+ "JRun4",
+ "org.hibernate.service.jta.platform.internal.JRun4JtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ OC4JJtaPlatform.class,
+ "OC4J",
+ "org.hibernate.service.jta.platform.internal.OC4JJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ OrionJtaPlatform.class,
+ "Orion",
+ "org.hibernate.service.jta.platform.internal.OrionJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ ResinJtaPlatform.class,
+ "Resin",
+ "org.hibernate.service.jta.platform.internal.ResinJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ SunOneJtaPlatform.class,
+ "SunOne",
+ "org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ WeblogicJtaPlatform.class,
+ "Weblogic",
+ "org.hibernate.service.jta.platform.internal.WeblogicJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ WebSphereJtaPlatform.class,
+ "WebSphere",
+ "org.hibernate.service.jta.platform.internal.WebSphereJtaPlatform"
+ );
+
+ addJtaPlatforms(
+ strategySelector,
+ WebSphereExtendedJtaPlatform.class,
+ "WebSphereExtended",
+ "org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform"
+ );
+ }
+
+ private void addJtaPlatforms(StrategySelectorImpl strategySelector, Class extends JtaPlatform> impl, String... names) {
+ for ( String name : names ) {
+ strategySelector.registerStrategyImplementor( JtaPlatform.class, name, impl );
+ }
+ }
+
+ private void addTransactionFactories(StrategySelectorImpl strategySelector) {
+ strategySelector.registerStrategyImplementor( TransactionFactory.class, JdbcTransactionFactory.SHORT_NAME, JdbcTransactionFactory.class );
+ strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JDBCTransactionFactory", JdbcTransactionFactory.class );
+
+ strategySelector.registerStrategyImplementor( TransactionFactory.class, JtaTransactionFactory.SHORT_NAME, JtaTransactionFactory.class );
+ strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.JTATransactionFactory", JtaTransactionFactory.class );
+
+ strategySelector.registerStrategyImplementor( TransactionFactory.class, CMTTransactionFactory.SHORT_NAME, CMTTransactionFactory.class );
+ strategySelector.registerStrategyImplementor( TransactionFactory.class, "org.hibernate.transaction.CMTTransactionFactory", CMTTransactionFactory.class );
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java
new file mode 100644
index 0000000000..9d7c6b98e4
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/StrategySelectorImpl.java
@@ -0,0 +1,161 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry.selector.internal;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.logging.Logger;
+
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
+
+/**
+ * @author Steve Ebersole
+ */
+public class StrategySelectorImpl implements StrategySelector {
+ private static final Logger log = Logger.getLogger( StrategySelectorImpl.class );
+
+ private final Map> namedStrategyImplementorByStrategyMap
+ = new ConcurrentHashMap>();
+
+ private final ClassLoaderService classLoaderService;
+
+ public StrategySelectorImpl(ClassLoaderService classLoaderService) {
+ this.classLoaderService = classLoaderService;
+ }
+
+ @Override
+ public void registerStrategyImplementor(Class strategy, String name, Class extends T> implementation) {
+ Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
+ if ( namedStrategyImplementorMap == null ) {
+ namedStrategyImplementorMap = new ConcurrentHashMap();
+ namedStrategyImplementorByStrategyMap.put( strategy, namedStrategyImplementorMap );
+ }
+
+ Class old = namedStrategyImplementorMap.put( name, implementation );
+ if ( old == null ) {
+ log.trace(
+ String.format(
+ "Registering named strategy selector [%s] : [%s] -> [%s]",
+ strategy.getName(),
+ name,
+ implementation.getName()
+ )
+ );
+ }
+ else {
+ log.debug(
+ String.format(
+ "Registering named strategy selector [%s] : [%s] -> [%s] (replacing [%s])",
+ strategy.getName(),
+ name,
+ implementation.getName(),
+ old.getName()
+ )
+ );
+ }
+ }
+
+ @Override
+ public void unRegisterStrategyImplementor(Class strategy, Class extends T> implementation) {
+ Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
+ if ( namedStrategyImplementorMap == null ) {
+ log.debug( "Named strategy map did not exist on call to un-register" );
+ return;
+ }
+
+ final Iterator itr = namedStrategyImplementorMap.values().iterator();
+ while ( itr.hasNext() ) {
+ final Class registered = (Class) itr.next();
+ if ( registered.equals( implementation ) ) {
+ itr.remove();
+ }
+ }
+
+ // try tp clean up after ourselves...
+ if ( namedStrategyImplementorMap.isEmpty() ) {
+ namedStrategyImplementorByStrategyMap.remove( strategy );
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Class extends T> selectStrategyImplementor(Class strategy, String name) {
+ Map namedStrategyImplementorMap = namedStrategyImplementorByStrategyMap.get( strategy );
+ if ( namedStrategyImplementorMap != null ) {
+ final Class registered = namedStrategyImplementorMap.get( name );
+ if ( registered != null ) {
+ return (Class) registered;
+ }
+ }
+
+ try {
+ return classLoaderService.classForName( name );
+ }
+ catch (ClassLoadingException e) {
+ throw new StrategySelectionException(
+ "Unable to resolve name [" + name + "] as strategy [" + strategy.getName() + "]"
+ );
+ }
+ }
+
+ @Override
+ public T resolveStrategy(Class strategy, Object strategyReference) {
+ return resolveDefaultableStrategy( strategy, strategyReference, null );
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T resolveDefaultableStrategy(Class strategy, Object strategyReference, T defaultValue) {
+ if ( strategyReference == null ) {
+ return defaultValue;
+ }
+
+ if ( strategy.isInstance( strategyReference ) ) {
+ return strategy.cast( strategyReference );
+ }
+
+ final Class extends T> implementationClass;
+ if ( Class.class.isInstance( strategyReference ) ) {
+ implementationClass = (Class) strategyReference;
+ }
+ else {
+ implementationClass = selectStrategyImplementor( strategy, strategyReference.toString() );
+ }
+
+ try {
+ return implementationClass.newInstance();
+ }
+ catch (Exception e) {
+ throw new StrategySelectionException(
+ String.format( "Could not instantiate named strategy class [%s]", implementationClass.getName() ),
+ e
+ );
+ }
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java
new file mode 100644
index 0000000000..095e5ca34b
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/package-info.java
@@ -0,0 +1 @@
+package org.hibernate.boot.registry.selector;
\ No newline at end of file
diff --git a/hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java
similarity index 59%
rename from hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java
rename to hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java
index 5ff5e054f1..01b63580be 100644
--- a/hibernate-core/src/test/java/org/hibernate/jmx/TrivialTest.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelectionException.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -21,36 +21,19 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.jmx;
+package org.hibernate.boot.registry.selector.spi;
-import org.junit.Test;
-
-import org.hibernate.testing.junit4.BaseUnitTestCase;
+import org.hibernate.HibernateException;
/**
* @author Steve Ebersole
*/
-public class TrivialTest extends BaseUnitTestCase {
- @Test
- public void testService() throws Exception {
- HibernateService hs = new HibernateService();
- hs.setJndiName( "SessionFactory" );
- hs.setMapResources( "org/hibernate/jmx/Entity.hbm.xml" );
- hs.setShowSqlEnabled( "true" );
- hs.start();
- hs.stop();
- hs.setProperty( "foo", "bar" );
- hs.start();
- hs.stop();
- try {
- hs.setMapResources( "non-existent" );
- hs.start();
- }
- catch( Throwable t ) {
- // expected behavior
- }
- finally {
- hs.stop();
- }
+public class StrategySelectionException extends HibernateException {
+ public StrategySelectionException(String message) {
+ super( message );
+ }
+
+ public StrategySelectionException(String message, Throwable root) {
+ super( message, root );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java
new file mode 100644
index 0000000000..21012a25fb
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/selector/spi/StrategySelector.java
@@ -0,0 +1,98 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.boot.registry.selector.spi;
+
+import org.hibernate.service.Service;
+
+/**
+ * Service which acts as a registry for named strategy implementations.
+ *
+ * @author Steve Ebersole
+ */
+public interface StrategySelector extends Service {
+ /**
+ * Registers a named implementor of a particular strategy contract.
+ *
+ * @param strategy The strategy contract.
+ * @param name The registration name
+ * @param implementation The implementation Class
+ */
+ public void registerStrategyImplementor(Class strategy, String name, Class extends T> implementation);
+
+ /**
+ * Un-registers a named implementor of a particular strategy contract. Un-registers all named registrations
+ * for the given strategy contract naming the given class.
+ *
+ * @param strategy The strategy contract.
+ * @param implementation The implementation Class
+ */
+ public void unRegisterStrategyImplementor(Class strategy, Class extends T> implementation);
+
+ /**
+ * Locate the named strategy implementation.
+ *
+ * @param strategy The type of strategy to be resolved.
+ * @param name The name of the strategy to locate; might be either a registered name or the implementation FQN.
+ *
+ * @return The named strategy implementation class.
+ */
+ public Class extends T> selectStrategyImplementor(Class strategy, String name);
+
+ /**
+ * Resolve strategy instances. See discussion on {@link #resolveDefaultableStrategy}.
+ * Only difference is that here, the implied default value is {@code null}.
+ *
+ * @param strategy The type (interface) of the strategy to be resolved.
+ * @param strategyReference The reference to the strategy for which we need to resolve an instance.
+ *
+ * @return The strategy instance
+ */
+ public T resolveStrategy(Class strategy, Object strategyReference);
+
+ /**
+ * Resolve strategy instances. The incoming reference might be:
+ *
+ * {@code null} - in which case defaultValue is returned.
+ *
+ *
+ * An actual instance of the strategy type - it is returned, as is
+ *
+ *
+ * A reference to the implementation {@link Class} - an instance is created by calling
+ * {@link Class#newInstance()} (aka, the class's no-arg ctor).
+ *
+ *
+ * The name of the implementation class - First the implementation's {@link Class} reference
+ * is resolved, and then an instance is created by calling {@link Class#newInstance()}
+ *
+ *
+ *
+ * @param strategy The type (interface) of the strategy to be resolved.
+ * @param strategyReference The reference to the strategy for which we need to resolve an instance.
+ * @param defaultValue THe default value to use if strategyReference is null
+ *
+ * @return The strategy instance
+ */
+ public T resolveDefaultableStrategy(Class strategy, Object strategyReference, T defaultValue);
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java b/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java
index 1182ed9d18..e3c4bd8513 100644
--- a/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java
+++ b/hibernate-core/src/main/java/org/hibernate/bytecode/buildtime/internal/JavassistInstrumenter.java
@@ -25,9 +25,13 @@ package org.hibernate.bytecode.buildtime.internal;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;
+import javassist.ClassClassPath;
+import javassist.ClassPool;
import javassist.bytecode.ClassFile;
import org.hibernate.bytecode.buildtime.spi.AbstractInstrumenter;
@@ -44,6 +48,7 @@ import org.hibernate.bytecode.spi.ClassTransformer;
*
* @author Steve Ebersole
* @author Muga Nishizawa
+ * @author Dustin Schultz
*/
public class JavassistInstrumenter extends AbstractInstrumenter {
@@ -70,6 +75,20 @@ public class JavassistInstrumenter extends AbstractInstrumenter {
return provider.getTransformer( CLASS_FILTER, new CustomFieldFilter( descriptor, classNames ) );
}
}
+
+ @Override
+ public void execute(Set files) {
+ ClassPool cp = ClassPool.getDefault();
+ cp.insertClassPath(new ClassClassPath(this.getClass()));
+ try {
+ for (File file : files) {
+ cp.makeClass(new FileInputStream(file));
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ super.execute(files);
+ }
private static class CustomClassDescriptor implements ClassDescriptor {
private final byte[] bytes;
diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java
index 4757612b80..300238fee4 100644
--- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java
+++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/javassist/FieldTransformer.java
@@ -32,6 +32,7 @@ import java.util.Iterator;
import java.util.List;
import javassist.CannotCompileException;
+import javassist.ClassPool;
import javassist.bytecode.AccessFlag;
import javassist.bytecode.BadBytecode;
import javassist.bytecode.Bytecode;
@@ -43,6 +44,8 @@ import javassist.bytecode.Descriptor;
import javassist.bytecode.FieldInfo;
import javassist.bytecode.MethodInfo;
import javassist.bytecode.Opcode;
+import javassist.bytecode.StackMapTable;
+import javassist.bytecode.stackmap.MapMaker;
/**
* The thing that handles actual class enhancement in regards to
@@ -50,6 +53,7 @@ import javassist.bytecode.Opcode;
*
* @author Muga Nishizawa
* @author Steve Ebersole
+ * @author Dustin Schultz
*/
public class FieldTransformer {
@@ -130,7 +134,7 @@ public class FieldTransformer {
}
private void addGetFieldHandlerMethod(ClassFile classfile)
- throws CannotCompileException {
+ throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME,
@@ -148,11 +152,13 @@ public class FieldTransformer {
code.addOpcode(Opcode.ARETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
+ StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
+ minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
private void addSetFieldHandlerMethod(ClassFile classfile)
- throws CannotCompileException {
+ throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME,
@@ -172,6 +178,8 @@ public class FieldTransformer {
code.addOpcode(Opcode.RETURN);
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
+ StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
+ minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
@@ -185,7 +193,7 @@ public class FieldTransformer {
}
private void addReadWriteMethods(ClassFile classfile)
- throws CannotCompileException {
+ throws CannotCompileException, BadBytecode {
List fields = classfile.getFields();
for (Iterator field_iter = fields.iterator(); field_iter.hasNext();) {
FieldInfo finfo = (FieldInfo) field_iter.next();
@@ -205,7 +213,7 @@ public class FieldTransformer {
}
private void addReadMethod(ClassFile classfile, FieldInfo finfo)
- throws CannotCompileException {
+ throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
String desc = "()" + finfo.getDescriptor();
@@ -254,11 +262,13 @@ public class FieldTransformer {
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
+ StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
+ minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
private void addWriteMethod(ClassFile classfile, FieldInfo finfo)
- throws CannotCompileException {
+ throws CannotCompileException, BadBytecode {
ConstPool cp = classfile.getConstPool();
int this_class_index = cp.getThisClassInfo();
String desc = "(" + finfo.getDescriptor() + ")V";
@@ -320,11 +330,13 @@ public class FieldTransformer {
minfo.setCodeAttribute(code.toCodeAttribute());
minfo.setAccessFlags(AccessFlag.PUBLIC);
+ StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
+ minfo.getCodeAttribute().setAttribute(smt);
classfile.addMethod(minfo);
}
private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile)
- throws CannotCompileException {
+ throws CannotCompileException, BadBytecode {
List methods = classfile.getMethods();
for (Iterator method_iter = methods.iterator(); method_iter.hasNext();) {
MethodInfo minfo = (MethodInfo) method_iter.next();
@@ -341,15 +353,13 @@ public class FieldTransformer {
}
CodeIterator iter = codeAttr.iterator();
while (iter.hasNext()) {
- try {
- int pos = iter.next();
- pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
- pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
-
- } catch (BadBytecode e) {
- throw new CannotCompileException(e);
- }
+ int pos = iter.next();
+ pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
+ pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
}
+
+ StackMapTable smt = MapMaker.make(ClassPool.getDefault(), minfo);
+ minfo.getCodeAttribute().setAttribute(smt);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java
index 413d433504..c7db90429f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java
@@ -33,7 +33,6 @@ import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
@@ -43,7 +42,7 @@ import org.hibernate.cache.spi.access.AccessType;
* @author Steve Ebersole
*/
public class NoCachingRegionFactory extends AbstractRegionFactory {
- public static RegionFactory INSTANCE = new NoCachingRegionFactory();
+ public static NoCachingRegionFactory INSTANCE = new NoCachingRegionFactory();
@Override
public void start() {
diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java
index f4ec97c8f4..f4346f19d2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java
@@ -25,14 +25,16 @@ package org.hibernate.cache.internal;
import org.jboss.logging.Logger;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@@ -72,50 +74,21 @@ public class RegionFactoryInitiator implements SessionFactoryServiceInitiator customImplClass = null;
- if ( Class.class.isInstance( impl ) ) {
- customImplClass = (Class extends RegionFactory>) impl;
- }
- else {
- customImplClass = registry.getService( ClassLoaderService.class )
- .classForName( mapLegacyNames( impl.toString() ) );
- }
-
- try {
- factory = customImplClass.newInstance();
- }
- catch ( Exception e ) {
- throw new ServiceException(
- "Could not initialize custom RegionFactory impl [" + customImplClass.getName() + "]", e
- );
- }
- }
+ return NoCachingRegionFactory.INSTANCE;
}
- return factory;
+ final Object setting = registry.getService( ConfigurationService.class ).getSettings().get( IMPL_NAME );
+ return registry.getService( StrategySelector.class ).resolveDefaultableStrategy(
+ RegionFactory.class,
+ setting,
+ NoCachingRegionFactory.INSTANCE
+ );
}
private static boolean isCacheEnabled(ServiceRegistryImplementor serviceRegistry) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java
index 98cc95f81d..6b1cc74e18 100644
--- a/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java
+++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/StandardQueryCache.java
@@ -40,10 +40,10 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.type.Type;
import org.hibernate.type.TypeHelper;
diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java
index 20caab53c9..43faa5a6cd 100644
--- a/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java
@@ -1,3 +1,26 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.cache.spi;
import java.util.Properties;
@@ -8,8 +31,8 @@ import org.hibernate.cache.CacheException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Settings;
import org.hibernate.cfg.SettingsFactory;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
index a84adf7b8a..2436835277 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
@@ -53,6 +53,7 @@ import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@@ -1393,17 +1394,42 @@ public final class AnnotationBinder {
if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
String columnName = element.getAnnotation( Column.class ).name();
for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
- if ( prop.isAnnotationPresent( JoinColumn.class )
- && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )
- && !prop.isAnnotationPresent( MapsId.class ) ) {
- //create a PropertyData fpr the specJ property holding the mapping
- PropertyData specJPropertyData = new PropertyInferredData(
- declaringClass, //same dec
- prop, // the actual @XToOne property
- propertyAccessor, //TODO we should get the right accessor but the same as id would do
- mappings.getReflectionManager()
- );
- mappings.addPropertyAnnotatedWithMapsIdSpecj( entity, specJPropertyData, element.toString() );
+ if ( !prop.isAnnotationPresent( MapsId.class ) ) {
+ /**
+ * The detection of a configured individual JoinColumn differs between Annotation
+ * and XML configuration processing.
+ */
+ boolean isRequiredAnnotationPresent = false;
+ JoinColumns groupAnnotation = prop.getAnnotation( JoinColumns.class );
+ if ( (prop.isAnnotationPresent( JoinColumn.class )
+ && prop.getAnnotation( JoinColumn.class ).name().equals( columnName )) ) {
+ isRequiredAnnotationPresent = true;
+ }
+ else if ( prop.isAnnotationPresent( JoinColumns.class ) ) {
+ for ( JoinColumn columnAnnotation : groupAnnotation.value() ) {
+ if ( columnName.equals( columnAnnotation.name() ) ) {
+ isRequiredAnnotationPresent = true;
+ break;
+ }
+ }
+ }
+ if ( isRequiredAnnotationPresent ) {
+ //create a PropertyData fpr the specJ property holding the mapping
+ PropertyData specJPropertyData = new PropertyInferredData(
+ declaringClass,
+ //same dec
+ prop,
+ // the actual @XToOne property
+ propertyAccessor,
+ //TODO we should get the right accessor but the same as id would do
+ mappings.getReflectionManager()
+ );
+ mappings.addPropertyAnnotatedWithMapsIdSpecj(
+ entity,
+ specJPropertyData,
+ element.toString()
+ );
+ }
}
}
}
@@ -2495,7 +2521,7 @@ public final class AnnotationBinder {
value.setColumns( columns );
value.setPersistentClassName( persistentClassName );
value.setMappings( mappings );
- value.setType( inferredData.getProperty(), inferredData.getClassOrElement() );
+ value.setType( inferredData.getProperty(), inferredData.getClassOrElement(), persistentClassName );
value.setAccessType( propertyAccessor );
id = value.make();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
index 90ca1d159c..3241b14c2a 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
@@ -44,10 +44,10 @@ public interface AvailableSettings {
public static final String SESSION_FACTORY_NAME_IS_JNDI = "hibernate.session_factory_name_is_jndi";
/**
- * Names the {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} to use for obtaining
+ * Names the {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} to use for obtaining
* JDBC connections. Can either reference an instance of
- * {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} or a {@link Class} or {@link String}
- * reference to the {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider} implementation
+ * {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} or a {@link Class} or {@link String}
+ * reference to the {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} implementation
* class.
*/
public static final String CONNECTION_PROVIDER ="hibernate.connection.provider_class";
@@ -64,7 +64,7 @@ public interface AvailableSettings {
/**
* Names the connection user. This might mean one of 2 things in out-of-the-box Hibernate
- * {@link org.hibernate.service.jdbc.connections.spi.ConnectionProvider}:
+ * {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider}:
* The username used to pass along to creating the JDBC connection
* The username used to obtain a JDBC connection from a data source
*
@@ -129,8 +129,8 @@ public interface AvailableSettings {
public static final String DIALECT ="hibernate.dialect";
/**
- * Names any additional {@link org.hibernate.service.jdbc.dialect.spi.DialectResolver} implementations to
- * register with the standard {@link org.hibernate.service.jdbc.dialect.spi.DialectFactory}.
+ * Names any additional {@link org.hibernate.engine.jdbc.dialect.spi.DialectResolver} implementations to
+ * register with the standard {@link org.hibernate.engine.jdbc.dialect.spi.DialectFactory}.
*/
public static final String DIALECT_RESOLVERS = "hibernate.dialect_resolvers";
@@ -275,30 +275,13 @@ public interface AvailableSettings {
public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
/**
- * Names the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use for integrating
- * with {@literal JTA} systems. Can reference either a {@link org.hibernate.service.jta.platform.spi.JtaPlatform}
- * instance or the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation class
+ * Names the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation to use for integrating
+ * with {@literal JTA} systems. Can reference either a {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform}
+ * instance or the name of the {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation class
* @since 4.0
*/
public static final String JTA_PLATFORM = "hibernate.transaction.jta.platform";
- /**
- * Names the {@link org.hibernate.transaction.TransactionManagerLookup} implementation to use for obtaining
- * reference to the {@literal JTA} {@link javax.transaction.TransactionManager}
- *
- * @deprecated See {@link #JTA_PLATFORM}
- */
- @Deprecated
- public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class";
-
- /**
- * JNDI name of JTA UserTransaction object
- *
- * @deprecated See {@link #JTA_PLATFORM}
- */
- @Deprecated
- public static final String USER_TRANSACTION = "jta.UserTransaction";
-
/**
* The {@link org.hibernate.cache.spi.RegionFactory} implementation class
*/
@@ -570,9 +553,9 @@ public interface AvailableSettings {
public static final String MULTI_TENANT = "hibernate.multiTenancy";
/**
- * Names a {@link org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider} implementation to
+ * Names a {@link org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider} implementation to
* use. As MultiTenantConnectionProvider is also a service, can be configured directly through the
- * {@link org.hibernate.service.ServiceRegistryBuilder}
+ * {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}
*
* @since 4.1
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
index c51da15230..6c5724f5a0 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
@@ -81,6 +81,7 @@ import org.hibernate.annotations.common.reflection.MetadataProviderInjector;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.annotations.reflection.JPAMetadataProvider;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.dialect.Dialect;
@@ -136,8 +137,7 @@ import org.hibernate.mapping.UniqueKey;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.internal.JACCConfiguration;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.IndexMetadata;
import org.hibernate.tool.hbm2ddl.TableMetadata;
@@ -163,7 +163,7 @@ import org.hibernate.usertype.UserType;
* A new Configuration will use the properties specified in
* hibernate.properties by default.
*
- * NOTE : This will be replaced by use of {@link ServiceRegistryBuilder} and
+ * NOTE : This will be replaced by use of {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} and
* {@link org.hibernate.metamodel.MetadataSources} instead after the 4.0 release at which point this class will become
* deprecated and scheduled for removal in 5.0. See
* HHH-6183 ,
@@ -1425,7 +1425,7 @@ public class Configuration implements Serializable {
if ( sp.isInPrimaryKey() ) {
String referenceEntityName = sp.getReferencedEntityName();
PersistentClass classMapping = getClassMapping( referenceEntityName );
- String dependentTable = classMapping.getTable().getQuotedName();
+ String dependentTable = quotedTableName(classMapping.getTable());
if ( !isADependencyOf.containsKey( dependentTable ) ) {
isADependencyOf.put( dependentTable, new HashSet() );
}
@@ -1495,7 +1495,7 @@ public class Configuration implements Serializable {
}
for ( FkSecondPass sp : dependencies ) {
- String dependentTable = sp.getValue().getTable().getQuotedName();
+ String dependentTable = quotedTableName(sp.getValue().getTable());
if ( dependentTable.compareTo( startTable ) == 0 ) {
StringBuilder sb = new StringBuilder(
"Foreign key circularity dependency involving the following tables: "
@@ -1509,6 +1509,10 @@ public class Configuration implements Serializable {
}
}
+ private String quotedTableName(Table table) {
+ return Table.qualify( table.getCatalog(), table.getQuotedSchema(), table.getQuotedName() );
+ }
+
private void processEndOfQueue(List endOfQueueFkSecondPasses) {
/*
* If a second pass raises a recoverableException, queue it for next round
@@ -1770,7 +1774,7 @@ public class Configuration implements Serializable {
public SessionFactory buildSessionFactory() throws HibernateException {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
- final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
+ final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings( properties )
.buildServiceRegistry();
setSessionFactoryObserver(
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
index 825d156386..8cc6667472 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
@@ -76,7 +76,7 @@ import org.hibernate.internal.util.config.ConfigurationHelper;
*
*
* hibernate.connection.provider_class
- * classname of org.hibernate.service.jdbc.connections.spi.ConnectionProvider
+ * classname of ConnectionProvider
* subclass (if not specified hueristics are used)
*
* hibernate.connection.username database username
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
index 01ba5d01d7..5a69fabd6f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/HbmBinder.java
@@ -95,6 +95,7 @@ import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UnionSubclass;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.mapping.Value;
+import org.hibernate.type.BasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type;
@@ -1212,6 +1213,11 @@ public final class HbmBinder {
}
}
+ resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters);
+ }
+
+ private static void resolveAndBindTypeDef(SimpleValue simpleValue,
+ Mappings mappings, String typeName, Properties parameters) {
TypeDef typeDef = mappings.getTypeDef( typeName );
if ( typeDef != null ) {
typeName = typeDef.getTypeClass();
@@ -1221,6 +1227,19 @@ public final class HbmBinder {
allParameters.putAll( typeDef.getParameters() );
allParameters.putAll( parameters );
parameters = allParameters;
+ }else if (typeName!=null && !mappings.isInSecondPass()){
+ BasicType basicType=mappings.getTypeResolver().basic(typeName);
+ if (basicType==null) {
+ /*
+ * If the referenced typeName isn't a basic-type, it's probably a typedef defined
+ * in a mapping file not read yet.
+ * It should be solved by deferring the resolution and binding of this type until
+ * all mapping files are read - the second passes.
+ * Fixes issue HHH-7300
+ */
+ SecondPass resolveUserTypeMappingSecondPass=new ResolveUserTypeMappingSecondPass(simpleValue,typeName,mappings,parameters);
+ mappings.addSecondPass(resolveUserTypeMappingSecondPass);
+ }
}
if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters );
@@ -3148,4 +3167,27 @@ public final class HbmBinder {
private static interface EntityElementHandler {
public void handleEntity(String entityName, String className, Mappings mappings);
}
+
+ private static class ResolveUserTypeMappingSecondPass implements SecondPass{
+
+ private SimpleValue simpleValue;
+ private String typeName;
+ private Mappings mappings;
+ private Properties parameters;
+
+ public ResolveUserTypeMappingSecondPass(SimpleValue simpleValue,
+ String typeName, Mappings mappings, Properties parameters) {
+ this.simpleValue=simpleValue;
+ this.typeName=typeName;
+ this.parameters=parameters;
+ this.mappings=mappings;
+ }
+
+ @Override
+ public void doSecondPass(java.util.Map persistentClasses)
+ throws MappingException {
+ resolveAndBindTypeDef(simpleValue, mappings, typeName, parameters);
+ }
+
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java b/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java
index a72f0babe3..d687f9e846 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Settings.java
@@ -30,7 +30,7 @@ import org.hibernate.EntityMode;
import org.hibernate.MultiTenancyStrategy;
import org.hibernate.cache.spi.QueryCacheFactory;
import org.hibernate.hql.spi.QueryTranslatorFactory;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java b/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java
index af877efa78..adee169384 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java
@@ -45,11 +45,11 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
index 50e312f940..e0d64516fc 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
@@ -1316,7 +1316,7 @@ public abstract class CollectionBinder {
column.setTable( collValue.getCollectionTable() );
}
elementBinder.setColumns( elementColumns );
- elementBinder.setType( property, elementClass );
+ elementBinder.setType( property, elementClass, collValue.getOwnerEntityName() );
elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
elementBinder.setAccessType( accessType );
collValue.setElement( elementBinder.make() );
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
index d62ddc3fb0..4883499bf5 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
@@ -282,7 +282,7 @@ public class MapBinder extends CollectionBinder {
elementBinder.setExplicitType( mapKeyTypeAnnotation.value() );
}
else {
- elementBinder.setType( property, elementClass );
+ elementBinder.setType( property, elementClass, this.collection.getOwnerEntityName() );
}
elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
elementBinder.setAccessType( accessType );
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
index b4251816b7..27e9235a89 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
@@ -185,7 +185,7 @@ public class PropertyBinder {
simpleValueBinder.setReturnedClassName( returnedClassName );
simpleValueBinder.setColumns( columns );
simpleValueBinder.setPersistentClassName( containerClassName );
- simpleValueBinder.setType( property, returnedClass );
+ simpleValueBinder.setType( property, returnedClass, containerClassName );
simpleValueBinder.setMappings( mappings );
simpleValueBinder.setReferencedEntityName( referencedEntityName );
simpleValueBinder.setAccessType( accessType );
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
index 2930f55c12..e8c46256ef 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
@@ -142,10 +142,11 @@ public class SimpleValueBinder {
//TODO execute it lazily to be order safe
- public void setType(XProperty property, XClass returnedClass) {
+ public void setType(XProperty property, XClass returnedClass, String declaringClassName) {
if ( returnedClass == null ) {
+ // we cannot guess anything
return;
- } //we cannot guess anything
+ }
XClass returnedClassOrElement = returnedClass;
boolean isArray = false;
if ( property.isArray() ) {
@@ -239,6 +240,17 @@ public class SimpleValueBinder {
}
else if ( ( !key && property.isAnnotationPresent( Enumerated.class ) )
|| ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) ) {
+ final Class attributeJavaType = mappings.getReflectionManager().toClass( returnedClassOrElement );
+ if ( !Enum.class.isAssignableFrom( attributeJavaType ) ) {
+ throw new AnnotationException(
+ String.format(
+ "Attribute [%s.%s] was annotated as enumerated, but its java type is not an enum [%s]",
+ declaringClassName,
+ xproperty.getName(),
+ attributeJavaType.getName()
+ )
+ );
+ }
type = EnumType.class.getName();
explicitType = type;
}
@@ -629,4 +641,4 @@ public class SimpleValueBinder {
public void setAccessType(AccessType accessType) {
this.accessType = accessType;
}
-}
\ No newline at end of file
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
index b4873e9b5e..032c3f9842 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
@@ -41,8 +41,8 @@ import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
index e3ea8b5761..4e5508d362 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
@@ -44,6 +44,8 @@ import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cfg.beanvalidation.ddl.DigitsSchemaConstraint;
import org.hibernate.cfg.beanvalidation.ddl.LengthSchemaConstraint;
import org.hibernate.cfg.beanvalidation.ddl.MaxSchemaConstraint;
@@ -63,8 +65,6 @@ import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
/**
* @author Emmanuel Bernard
diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java
index d3912a4928..02ea3a6f4e 100644
--- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java
+++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java
@@ -271,14 +271,35 @@ public class PersistentMap extends AbstractPersistentCollection implements Map {
return map.toString();
}
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
- if ( element!=null ) map.put(index, element);
+ private transient List loadingEntries;
+
+ public Object readFrom(
+ ResultSet rs,
+ CollectionPersister persister,
+ CollectionAliases descriptor,
+ Object owner) throws HibernateException, SQLException {
+ final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ if ( element != null ) {
+ final Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
+ if ( loadingEntries == null ) {
+ loadingEntries = new ArrayList();
+ }
+ loadingEntries.add( new Object[] { index, element } );
+ }
return element;
}
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean endRead() {
+ if ( loadingEntries != null ) {
+ for ( Object[] entry : loadingEntries ) {
+ map.put( entry[0], entry[1] );
+ }
+ }
+ return super.endRead();
+ }
+
public Iterator entries(CollectionPersister persister) {
return map.entrySet().iterator();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java b/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java
index 5c4397bb34..f33a7e2502 100644
--- a/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java
@@ -39,7 +39,7 @@ import org.hibernate.context.spi.CurrentSessionContext;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* An implementation of {@link CurrentSessionContext} which scopes the notion
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java
index 67633c2c5c..4f93f7af25 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2400Dialect.java
@@ -71,4 +71,7 @@ public class DB2400Dialect extends DB2Dialect {
.toString();
}
+ public String getForUpdateString() {
+ return " for update with rs";
+ }
}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java
index de7950843f..deab2055b5 100755
--- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java
@@ -56,7 +56,9 @@ public class DerbyDialect extends DB2Dialect {
public DerbyDialect() {
super();
- LOG.deprecatedDerbyDialect();
+ if (this.getClass() == DerbyDialect.class) {
+ LOG.deprecatedDerbyDialect();
+ }
registerFunction( "concat", new DerbyConcatFunction() );
registerFunction( "trim", new AnsiTrimFunction() );
registerColumnType( Types.BLOB, "blob" );
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
index 4b579f0ec9..ffcefaaa68 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java
@@ -2409,4 +2409,14 @@ public abstract class Dialect implements ConversionContext {
// oddly most database in fact seem to, so true is the default.
return true;
}
+
+ /**
+ * Return the limit that the underlying database places on the number elements in an {@code IN} predicate.
+ * If the database defines no such limits, simply return zero or less-than-zero.
+ *
+ * @return int The limit, or zero-or-less to indicate no limit.
+ */
+ public int getInExpressionCountLimit() {
+ return 0;
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
index d2d33db4bc..40a5891f43 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
@@ -58,6 +58,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
* @author Steve Ebersole
*/
public class Oracle8iDialect extends Dialect {
+
+ private static final int PARAM_LIST_SIZE_LIMIT = 1000;
public Oracle8iDialect() {
super();
@@ -551,15 +553,22 @@ public class Oracle8iDialect extends Dialect {
return false;
}
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public boolean supportsEmptyInList() {
return false;
}
+
@Override
public boolean supportsExistsInSelect() {
return false;
}
+ /* (non-Javadoc)
+ * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
+ */
+ @Override
+ public int getInExpressionCountLimit() {
+ return PARAM_LIST_SIZE_LIMIT;
+ }
+
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
index b502e9c8e8..d0f0d8ce79 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
@@ -52,6 +52,8 @@ import org.hibernate.type.StandardBasicTypes;
*/
@Deprecated
public class Oracle9Dialect extends Dialect {
+
+ private static final int PARAM_LIST_SIZE_LIMIT = 1000;
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Oracle9Dialect.class.getName());
@@ -360,9 +362,6 @@ public class Oracle9Dialect extends Dialect {
return false;
}
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
public boolean supportsEmptyInList() {
return false;
}
@@ -370,4 +369,12 @@ public class Oracle9Dialect extends Dialect {
public boolean supportsExistsInSelect() {
return false;
}
+
+ /* (non-Javadoc)
+ * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
+ */
+ @Override
+ public int getInExpressionCountLimit() {
+ return PARAM_LIST_SIZE_LIMIT;
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
index 62b91492b9..90a9e4b829 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
@@ -39,6 +39,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
* @author Gavin King
*/
public class SQLServerDialect extends AbstractTransactSQLDialect {
+
+ private static final int PARAM_LIST_SIZE_LIMIT = 2100;
public SQLServerDialect() {
registerColumnType( Types.VARBINARY, "image" );
@@ -188,5 +190,13 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
protected SqlTypeDescriptor getSqlTypeDescriptorOverride( int sqlCode ) {
return sqlCode == Types.TINYINT ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride(sqlCode);
}
+
+ /* (non-Javadoc)
+ * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
+ */
+ @Override
+ public int getInExpressionCountLimit() {
+ return PARAM_LIST_SIZE_LIMIT;
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java
index 42dbbaf949..bb94974c5a 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java
@@ -29,7 +29,7 @@ import org.hibernate.sql.Sybase11JoinFragment;
* A SQL dialect suitable for use with Sybase 11.9.2 (specifically: avoids ANSI JOIN syntax)
* @author Colm O' Flaherty
*/
-public class Sybase11Dialect extends AbstractTransactSQLDialect {
+public class Sybase11Dialect extends SybaseDialect {
public Sybase11Dialect() {
super();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java
index 0836f4f394..423ced7cb7 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java
@@ -40,7 +40,7 @@ import org.hibernate.type.descriptor.sql.TinyIntTypeDescriptor;
*
* @author Gavin King
*/
-public class SybaseASE15Dialect extends AbstractTransactSQLDialect {
+public class SybaseASE15Dialect extends SybaseDialect {
public SybaseASE15Dialect() {
super();
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java
index a10a7da155..688c917c06 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java
@@ -30,7 +30,7 @@ package org.hibernate.dialect;
* (Tested on ASA 8.x)
* @author ?
*/
-public class SybaseAnywhereDialect extends AbstractTransactSQLDialect {
+public class SybaseAnywhereDialect extends SybaseDialect {
/**
* Sybase Anywhere syntax would require a "DEFAULT" for each column specified,
* but I suppose Hibernate use this syntax only with tables with just 1 column
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java
index a651f59d5e..13f333933c 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseDialect.java
@@ -25,16 +25,19 @@ package org.hibernate.dialect;
/**
- * This dialect is being deprecated; it had been used both as the base class
- * for TransactSQL-based dialects as well as the physical dialect for handling
- * Sybase. Those functions have now been split.
- * {@link AbstractTransactSQLDialect} should be used as the base class for
- * TransactSQL-based dialects.
+ * All Sybase dialects share an IN list size limit.
*
- * @deprecated use {@link AbstractTransactSQLDialect}, {@link SybaseASE15Dialect} or {@link SQLServerDialect}
- * instead depending on need.
- *
- * @author Gail Badner
+ * @author Brett Meyer
*/
public class SybaseDialect extends AbstractTransactSQLDialect {
+
+ private static final int PARAM_LIST_SIZE_LIMIT = 250000;
+
+ /* (non-Javadoc)
+ * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
+ */
+ @Override
+ public int getInExpressionCountLimit() {
+ return PARAM_LIST_SIZE_LIMIT;
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java
index e28a5a61ac..942057aa64 100644
--- a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java
+++ b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java
@@ -37,6 +37,8 @@ import org.hibernate.type.StandardBasicTypes;
* @author Jay Nance
*/
public class TeradataDialect extends Dialect {
+
+ private static final int PARAM_LIST_SIZE_LIMIT = 1024;
/**
* Constructor
@@ -256,4 +258,12 @@ public class TeradataDialect extends Dialect {
public boolean supportsBindAsCallableArgument() {
return false;
}
+
+ /* (non-Javadoc)
+ * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit()
+ */
+ @Override
+ public int getInExpressionCountLimit() {
+ return PARAM_LIST_SIZE_LIMIT;
+ }
}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java
index 4c03d5f844..5118c5e782 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.config.internal;
+package org.hibernate.engine.config.internal;
import java.util.Collections;
import java.util.Map;
@@ -29,9 +29,9 @@ import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.config.spi.ConfigurationService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java
similarity index 85%
rename from hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java
index 610734ca8f..ff382aeb87 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/config/internal/ConfigurationServiceInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java
@@ -21,18 +21,18 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.config.internal;
+package org.hibernate.engine.config.internal;
import java.util.Map;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class ConfigurationServiceInitiator implements BasicServiceInitiator {
+public class ConfigurationServiceInitiator implements StandardServiceInitiator {
public static final ConfigurationServiceInitiator INSTANCE = new ConfigurationServiceInitiator();
public ConfigurationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/spi/ConfigurationService.java b/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/config/spi/ConfigurationService.java
rename to hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java
index 6f8381f604..de5a4fb955 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/config/spi/ConfigurationService.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.config.spi;
+package org.hibernate.engine.config.spi;
import java.util.Map;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java
old mode 100644
new mode 100755
index b1807e9cec..1edeab7fd4
--- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/AbstractBatchImpl.java
@@ -135,19 +135,7 @@ public abstract class AbstractBatchImpl implements Batch {
}
private PreparedStatement buildBatchStatement(String sql, boolean callable) {
- sql = jdbcCoordinator.getTransactionCoordinator().getTransactionContext().onPrepareStatement( sql );
- try {
- if ( callable ) {
- return jdbcCoordinator.getLogicalConnection().getShareableConnectionProxy().prepareCall( sql );
- }
- else {
- return jdbcCoordinator.getLogicalConnection().getShareableConnectionProxy().prepareStatement( sql );
- }
- }
- catch ( SQLException sqle ) {
- LOG.sqlExceptionEscapedProxy( sqle );
- throw sqlExceptionHelper().convert( sqle, "could not prepare batch statement", sql );
- }
+ return jdbcCoordinator.getStatementPreparer().prepareStatement( sql, callable );
}
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java
index fda0204233..374a51edd3 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java
@@ -25,11 +25,11 @@ package org.hibernate.engine.jdbc.batch.internal;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@@ -38,7 +38,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
-public class BatchBuilderInitiator implements BasicServiceInitiator {
+public class BatchBuilderInitiator implements StandardServiceInitiator {
public static final BatchBuilderInitiator INSTANCE = new BatchBuilderInitiator();
public static final String BUILDER = "hibernate.jdbc.batch.builder";
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/ConnectionProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/ConnectionProviderInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java
index fc0fc667d5..cde05919ce 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/ConnectionProviderInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.internal;
+package org.hibernate.engine.jdbc.connections.internal;
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
@@ -36,13 +36,13 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.MultiTenancyStrategy;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.beans.BeanInfoHelper;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@@ -51,7 +51,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* @author Gavin King
* @author Steve Ebersole
*/
-public class ConnectionProviderInitiator implements BasicServiceInitiator {
+public class ConnectionProviderInitiator implements StandardServiceInitiator {
public static final ConnectionProviderInitiator INSTANCE = new ConnectionProviderInitiator();
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DatasourceConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DatasourceConnectionProviderImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java
index 98ba729b6a..71b6e7f10c 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DatasourceConnectionProviderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DatasourceConnectionProviderImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.internal;
+package org.hibernate.engine.jdbc.connections.internal;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
@@ -29,15 +29,15 @@ import javax.sql.DataSource;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jndi.spi.JndiService;
+import org.hibernate.engine.jndi.spi.JndiService;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.InjectService;
import org.hibernate.service.spi.Stoppable;
/**
- * A {@link ConnectionProvider} that manages connections from an underlying {@link DataSource}.
+ * A {@link org.hibernate.engine.jdbc.connections.spi.ConnectionProvider} that manages connections from an underlying {@link DataSource}.
*
* The {@link DataSource} to use may be specified by either:
* injection via {@link #setDataSource}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java
index 85f8874005..3b9d67da7b 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.internal;
+package org.hibernate.engine.jdbc.connections.internal;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -35,13 +35,13 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java
similarity index 85%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java
index 3605291df4..deedad18f7 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java
@@ -21,26 +21,26 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.internal;
+package org.hibernate.engine.jdbc.connections.internal;
import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.MultiTenancyStrategy;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.engine.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class MultiTenantConnectionProviderInitiator implements BasicServiceInitiator {
+public class MultiTenantConnectionProviderInitiator implements StandardServiceInitiator {
public static final MultiTenantConnectionProviderInitiator INSTANCE = new MultiTenantConnectionProviderInitiator();
private static final Logger log = Logger.getLogger( MultiTenantConnectionProviderInitiator.class );
@@ -60,7 +60,7 @@ public class MultiTenantConnectionProviderInitiator implements BasicServiceIniti
final Object configValue = configurationValues.get( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER );
if ( configValue == null ) {
// if they also specified the data source *name*, then lets assume they want
- // org.hibernate.service.jdbc.connections.spi.DataSourceBasedMultiTenantConnectionProviderImpl
+ // DataSourceBasedMultiTenantConnectionProviderImpl
final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE );
if ( dataSourceConfigValue != null && String.class.isInstance( dataSourceConfigValue ) ) {
return new DataSourceBasedMultiTenantConnectionProviderImpl();
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java
index f9927cf4e2..2d284ee199 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java
@@ -21,13 +21,14 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.internal;
+package org.hibernate.engine.jdbc.connections.internal;
import java.sql.Connection;
import java.sql.SQLException;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionException;
/**
* An implementation of the {@link ConnectionProvider} interface that simply throws an exception when a connection
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java
index 9c2bc3e2e5..b60d3433d0 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.spi;
+package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java
index 8460a96acf..cd543ec6be 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.spi;
+package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.java
index dd41e81a88..762d5b4613 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/ConnectionProvider.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.spi;
+package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java
index cbc119b054..cb387f1421 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/DataSourceBasedMultiTenantConnectionProviderImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.spi;
+package org.hibernate.engine.jdbc.connections.spi;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -30,8 +30,8 @@ import javax.sql.DataSource;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.jndi.spi.JndiService;
+import org.hibernate.engine.config.spi.ConfigurationService;
+import org.hibernate.engine.jndi.spi.JndiService;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.Stoppable;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/MultiTenantConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/MultiTenantConnectionProvider.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/MultiTenantConnectionProvider.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/MultiTenantConnectionProvider.java
index 29ce194997..860d926c0b 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/MultiTenantConnectionProvider.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/MultiTenantConnectionProvider.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.connections.spi;
+package org.hibernate.engine.jdbc.connections.spi;
import java.sql.Connection;
import java.sql.SQLException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/RefCursorSupportInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java
similarity index 84%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/RefCursorSupportInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java
index 7c7cc4fe11..2a74fe146e 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/RefCursorSupportInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java
@@ -21,18 +21,18 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.cursor.internal;
+package org.hibernate.engine.jdbc.cursor.internal;
import java.util.Map;
-import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class RefCursorSupportInitiator implements BasicServiceInitiator {
+public class RefCursorSupportInitiator implements StandardServiceInitiator {
public static final RefCursorSupportInitiator INSTANCE = new RefCursorSupportInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/StandardRefCursorSupport.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/StandardRefCursorSupport.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java
index cb48b29468..93f3e6a9de 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/internal/StandardRefCursorSupport.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/StandardRefCursorSupport.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.cursor.internal;
+package org.hibernate.engine.jdbc.cursor.internal;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -35,7 +35,7 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.spi.JdbcServices;
-import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
+import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.spi.InjectService;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/spi/RefCursorSupport.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/spi/RefCursorSupport.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/spi/RefCursorSupport.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/spi/RefCursorSupport.java
index 75babaaba8..7785f0954f 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/cursor/spi/RefCursorSupport.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/spi/RefCursorSupport.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.cursor.spi;
+package org.hibernate.engine.jdbc.cursor.spi;
import java.sql.CallableStatement;
import java.sql.ResultSet;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/AbstractDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/AbstractDialectResolver.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/AbstractDialectResolver.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/AbstractDialectResolver.java
index 4eab076eed..0d50ba37cf 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/AbstractDialectResolver.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/AbstractDialectResolver.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
@@ -33,7 +33,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.resolver.BasicSQLExceptionConverter;
import org.hibernate.exception.JDBCConnectionException;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
+import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
/**
* A templated resolver impl which delegates to the {@link #resolveDialectInternal} method
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/BasicDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/BasicDialectResolver.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/BasicDialectResolver.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/BasicDialectResolver.java
index 0de006258e..79cd856ef3 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/BasicDialectResolver.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/BasicDialectResolver.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java
similarity index 79%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java
index 7c045603c9..b5ee361502 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -29,12 +29,11 @@ import java.sql.SQLException;
import java.util.Map;
import org.hibernate.HibernateException;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
-import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
+import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
+import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.service.spi.InjectService;
/**
@@ -43,11 +42,11 @@ import org.hibernate.service.spi.InjectService;
* @author Steve Ebersole
*/
public class DialectFactoryImpl implements DialectFactory {
- private ClassLoaderService classLoaderService;
+ private StrategySelector strategySelector;
@InjectService
- public void setClassLoaderService(ClassLoaderService classLoaderService) {
- this.classLoaderService = classLoaderService;
+ public void setStrategySelector(StrategySelector strategySelector) {
+ this.strategySelector = strategySelector;
}
private DialectResolver dialectResolver;
@@ -69,17 +68,19 @@ public class DialectFactoryImpl implements DialectFactory {
}
private Dialect constructDialect(String dialectName) {
+ final Dialect dialect;
try {
- return ( Dialect ) classLoaderService.classForName( dialectName ).newInstance();
+ dialect = strategySelector.resolveStrategy( Dialect.class, dialectName );
+ if ( dialect == null ) {
+ throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]" );
+ }
+ return dialect;
}
- catch ( ClassLoadingException e ) {
- throw new HibernateException( "Dialect class not found: " + dialectName, e );
- }
- catch ( HibernateException e ) {
+ catch (HibernateException e) {
throw e;
}
- catch ( Exception e ) {
- throw new HibernateException( "Could not instantiate dialect class", e );
+ catch (Exception e) {
+ throw new HibernateException( "Unable to construct requested dialect [" + dialectName+ "]", e );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java
similarity index 85%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java
index 0f2d7a3f05..a207465656 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectFactoryInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java
@@ -21,12 +21,12 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.util.Map;
-import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@@ -34,7 +34,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
-public class DialectFactoryInitiator implements BasicServiceInitiator {
+public class DialectFactoryInitiator implements StandardServiceInitiator {
public static final DialectFactoryInitiator INSTANCE = new DialectFactoryInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java
similarity index 89%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java
index aba44b5bad..bd48a88630 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.util.ArrayList;
import java.util.List;
@@ -30,9 +30,9 @@ import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.util.StringHelper;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@@ -41,7 +41,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
-public class DialectResolverInitiator implements BasicServiceInitiator {
+public class DialectResolverInitiator implements StandardServiceInitiator {
public static final DialectResolverInitiator INSTANCE = new DialectResolverInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverSet.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverSet.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverSet.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverSet.java
index 8577d8cc1d..ed11ab2c5d 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/DialectResolverSet.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverSet.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.util.ArrayList;
@@ -33,7 +33,7 @@ import org.jboss.logging.Logger;
import org.hibernate.dialect.Dialect;
import org.hibernate.exception.JDBCConnectionException;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
+import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
/**
* A {@link DialectResolver} implementation which coordinates resolution by delegating to sub-resolvers.
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/StandardDialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/StandardDialectResolver.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java
index 3e6c4dba52..f26633f1ea 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/internal/StandardDialectResolver.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/StandardDialectResolver.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.internal;
+package org.hibernate.engine.jdbc.dialect.internal;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectFactory.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectFactory.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java
index 33e9c1dcad..876666d6da 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.spi;
+package org.hibernate.engine.jdbc.dialect.spi;
import java.sql.Connection;
import java.util.Map;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectResolver.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectResolver.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectResolver.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectResolver.java
index 1adfae2ecf..67ef46b4b2 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/dialect/spi/DialectResolver.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectResolver.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jdbc.dialect.spi;
+package org.hibernate.engine.jdbc.dialect.spi;
import java.sql.DatabaseMetaData;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java
index daba12b7b1..baf652a1b9 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java
@@ -29,12 +29,12 @@ import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.ResultSetWrapper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.service.spi.Configurable;
@@ -50,9 +50,10 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi
private ServiceRegistryImplementor serviceRegistry;
private JdbcEnvironment jdbcEnvironment;
- private ConnectionProvider connectionProvider;
private SqlStatementLogger sqlStatementLogger;
+ private ConnectionProvider connectionProvider;
+
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
this.serviceRegistry = serviceRegistry;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java
index c404917a30..a1704b075a 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java
@@ -25,8 +25,8 @@ package org.hibernate.engine.jdbc.internal;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.jdbc.spi.JdbcServices;
-import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@@ -36,7 +36,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
-public class JdbcServicesInitiator implements BasicServiceInitiator {
+public class JdbcServicesInitiator implements StandardServiceInitiator {
public static final JdbcServicesInitiator INSTANCE = new JdbcServicesInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java
index c186ed1482..8da868ac57 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/JdbcServices.java
@@ -29,7 +29,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.service.Service;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiException.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiException.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/jndi/JndiException.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiException.java
index 13431d4a7a..b7047ddbc1 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiException.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiException.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jndi;
+package org.hibernate.engine.jndi;
import org.hibernate.HibernateException;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiNameException.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiNameException.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/jndi/JndiNameException.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiNameException.java
index 526a18276c..6114c6dbfa 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jndi/JndiNameException.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/JndiNameException.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jndi;
+package org.hibernate.engine.jndi;
import org.hibernate.HibernateException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceImpl.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java
index d149f2ce67..86a0882450 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jndi.internal;
+package org.hibernate.engine.jndi.internal;
import java.util.Hashtable;
import java.util.Map;
@@ -38,9 +38,9 @@ import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.jndi.JndiHelper;
-import org.hibernate.service.jndi.JndiException;
-import org.hibernate.service.jndi.JndiNameException;
-import org.hibernate.service.jndi.spi.JndiService;
+import org.hibernate.engine.jndi.JndiException;
+import org.hibernate.engine.jndi.JndiNameException;
+import org.hibernate.engine.jndi.spi.JndiService;
/**
* Standard implementation of JNDI services.
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java
similarity index 86%
rename from hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java
index 5cd32042bb..3280c04b26 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jndi/internal/JndiServiceInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java
@@ -21,12 +21,12 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jndi.internal;
+package org.hibernate.engine.jndi.internal;
import java.util.Map;
-import org.hibernate.service.jndi.spi.JndiService;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.engine.jndi.spi.JndiService;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@@ -34,7 +34,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
-public class JndiServiceInitiator implements BasicServiceInitiator {
+public class JndiServiceInitiator implements StandardServiceInitiator {
public static final JndiServiceInitiator INSTANCE = new JndiServiceInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jndi/spi/JndiService.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/spi/JndiService.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jndi/spi/JndiService.java
rename to hibernate-core/src/main/java/org/hibernate/engine/jndi/spi/JndiService.java
index 3e01849149..95905dd720 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jndi/spi/JndiService.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/spi/JndiService.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jndi.spi;
+package org.hibernate.engine.jndi.spi;
import javax.naming.event.NamespaceChangeListener;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java
index bb3c3e46f7..a0cc8853ee 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java
@@ -52,7 +52,7 @@ import org.hibernate.id.IdentifierGenerator;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.EntityNotFoundDelegate;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.type.Type;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java
index 2324686ab9..4fc91f54ed 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionCoordinatorImpl.java
@@ -51,7 +51,7 @@ import org.hibernate.engine.transaction.synchronization.internal.Synchronization
import org.hibernate.engine.transaction.synchronization.spi.SynchronizationCallbackCoordinator;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* Standard implementation of the Hibernate {@link TransactionCoordinator}
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java
index b38fbf2564..5cee1c627f 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/TransactionFactoryInitiator.java
@@ -27,17 +27,13 @@ import java.util.Map;
import org.jboss.logging.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
-import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
-import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@@ -46,7 +42,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
* @author Steve Ebersole
*/
public class TransactionFactoryInitiator
- implements BasicServiceInitiator {
+ implements StandardServiceInitiator {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
@@ -64,86 +60,14 @@ public class TransactionFactoryInitiator
@Override
@SuppressWarnings( {"unchecked"})
public TransactionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
- final Object strategy = configurationValues.get( Environment.TRANSACTION_STRATEGY );
+ final Object strategy = configurationValues.get( AvailableSettings.TRANSACTION_STRATEGY );
+
if ( strategy == null ) {
LOG.usingDefaultTransactionStrategy();
return new JdbcTransactionFactory();
}
- if ( TransactionFactory.class.isInstance( strategy ) ) {
- return (TransactionFactory) strategy;
- }
-
- Class extends TransactionFactory> transactionFactoryClass;
- if ( Class.class.isInstance( strategy ) ) {
- final Class theClass = (Class) strategy;
- LOG.transactionStrategy( theClass.getName() );
- try {
- transactionFactoryClass = (Class extends TransactionFactory>) theClass;
- }
- catch (ClassCastException e) {
- throw new ClassLoadingException(
- String.format(
- "TransactionFactory implementation class [%s] did not implement TransactionFactory interface",
- theClass.getName()
- )
- );
- }
- }
- else {
- final String strategyClassName = mapName( strategy.toString() );
- LOG.transactionStrategy( strategyClassName );
-
- try {
- transactionFactoryClass = registry.getService( ClassLoaderService.class ).classForName( strategyClassName );
- }
- catch (ClassCastException e) {
- throw new ClassLoadingException(
- String.format(
- "TransactionFactory implementation class [%s] did not implement TransactionFactory interface",
- strategyClassName
- )
- );
- }
- }
-
- try {
- return transactionFactoryClass.newInstance();
- }
- catch ( Exception e ) {
- throw new HibernateException( "Unable to instantiate specified TransactionFactory class [" + transactionFactoryClass.getName() + "]", e );
- }
- }
-
- private String mapName(String name) {
- // check legacy names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- if ( "org.hibernate.transaction.JDBCTransactionFactory".equals( name ) ) {
- return JdbcTransactionFactory.class.getName();
- }
-
- if ( "org.hibernate.transaction.JTATransactionFactory".equals( name ) ) {
- return JtaTransactionFactory.class.getName();
- }
-
- if ( "org.hibernate.transaction.CMTTransactionFactory".equals( name ) ) {
- return CMTTransactionFactory.class.getName();
- }
-
- // check short names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- if ( JdbcTransactionFactory.SHORT_NAME.endsWith( name ) ) {
- return JdbcTransactionFactory.class.getName();
- }
-
- if ( JtaTransactionFactory.SHORT_NAME.equals( name ) ) {
- return JtaTransactionFactory.class.getName();
- }
-
- if ( CMTTransactionFactory.SHORT_NAME.equals( name ) ) {
- return CMTTransactionFactory.class.getName();
- }
-
-
- return name;
+ return registry.getService( StrategySelector.class ).resolveStrategy( TransactionFactory.class, strategy );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java
index 539a800040..f0e50881b9 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaTransactionFactory.java
@@ -30,7 +30,7 @@ import org.hibernate.ConnectionReleaseMode;
import org.hibernate.TransactionException;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.engine.transaction.spi.TransactionFactory;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* Factory for {@link JtaTransaction} instances.
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java
similarity index 86%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java
index c05e261b3d..7ab85e783b 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.util.Map;
import javax.transaction.Synchronization;
@@ -33,8 +33,8 @@ import javax.transaction.UserTransaction;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jndi.spi.JndiService;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.jndi.spi.JndiService;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@@ -67,8 +67,24 @@ public abstract class AbstractJtaPlatform
protected abstract UserTransaction locateUserTransaction();
public void configure(Map configValues) {
- cacheTransactionManager = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_TM, configValues, true );
- cacheUserTransaction = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_UT, configValues, false );
+ cacheTransactionManager = ConfigurationHelper.getBoolean(
+ AvailableSettings.JTA_CACHE_TM,
+ configValues,
+ canCacheTransactionManagerByDefault()
+ );
+ cacheUserTransaction = ConfigurationHelper.getBoolean(
+ AvailableSettings.JTA_CACHE_UT,
+ configValues,
+ canCacheUserTransactionByDefault()
+ );
+ }
+
+ protected boolean canCacheTransactionManagerByDefault() {
+ return true;
+ }
+
+ protected boolean canCacheUserTransactionByDefault() {
+ return false;
}
protected boolean canCacheTransactionManager() {
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BitronixJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BitronixJtaPlatform.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BitronixJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BitronixJtaPlatform.java
index 17b2505c76..e6f5f925f9 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BitronixJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BitronixJtaPlatform.java
@@ -21,14 +21,14 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.lang.reflect.Method;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java
index 9144f8e113..49390a89d0 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/BorlandEnterpriseServerJtaPlatform.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java
similarity index 62%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java
index 92bef427a8..77c5a43afc 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossAppServerJtaPlatform.java
@@ -21,12 +21,12 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.hibernate.service.jndi.JndiException;
+import org.hibernate.engine.jndi.JndiException;
/**
* JtaPlatform definition for JBoss Application Server.
@@ -36,25 +36,46 @@ import org.hibernate.service.jndi.JndiException;
public class JBossAppServerJtaPlatform extends AbstractJtaPlatform {
public static final String AS7_TM_NAME = "java:jboss/TransactionManager";
public static final String AS4_TM_NAME = "java:/TransactionManager";
- public static final String UT_NAME = "java:comp/UserTransaction"; // should work with AS7 and earlier
+ public static final String JBOSS__UT_NAME = "java:jboss/UserTransaction";
+ public static final String UT_NAME = "java:comp/UserTransaction";
+
+ @Override
+ protected boolean canCacheUserTransactionByDefault() {
+ return true;
+ }
+
+ @Override
+ protected boolean canCacheTransactionManagerByDefault() {
+ return true;
+ }
@Override
protected TransactionManager locateTransactionManager() {
try {
- return (TransactionManager) jndiService().locate(AS7_TM_NAME);
+ return (TransactionManager) jndiService().locate( AS7_TM_NAME );
}
- catch(JndiException jndiException) {
+ catch (JndiException jndiException) {
try {
- return (TransactionManager) jndiService().locate(AS4_TM_NAME);
+ return (TransactionManager) jndiService().locate( AS4_TM_NAME );
}
- catch(JndiException jndiExceptionInner) {
- throw new JndiException("unable to find transaction manager", jndiException);
+ catch (JndiException jndiExceptionInner) {
+ throw new JndiException( "unable to find transaction manager", jndiException );
}
}
}
@Override
protected UserTransaction locateUserTransaction() {
- return (UserTransaction) jndiService().locate( UT_NAME );
+ try {
+ return (UserTransaction) jndiService().locate( JBOSS__UT_NAME );
+ }
+ catch (JndiException jndiException) {
+ try {
+ return (UserTransaction) jndiService().locate( UT_NAME );
+ }
+ catch (JndiException jndiExceptionInner) {
+ throw new JndiException( "unable to find UserTransaction", jndiException );
+ }
+ }
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossStandAloneJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossStandAloneJtaPlatform.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossStandAloneJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossStandAloneJtaPlatform.java
index 85f9861fd9..9ad1d0b871 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JBossStandAloneJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JBossStandAloneJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* Return a standalone JTA transaction manager for JBoss Transactions
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOTMJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOTMJtaPlatform.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOTMJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOTMJtaPlatform.java
index 9de4f7bc54..255d2bfb83 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOTMJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOTMJtaPlatform.java
@@ -21,14 +21,14 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.lang.reflect.Method;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOnASJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOnASJtaPlatform.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOnASJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOnASJtaPlatform.java
index b02c6b9218..7c2d16ca04 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JOnASJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JOnASJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.lang.reflect.Method;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* JTA platform implementation for JOnAS
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JRun4JtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JRun4JtaPlatform.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JRun4JtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JRun4JtaPlatform.java
index 2242bcdbb3..a23d78a018 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JRun4JtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JRun4JtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
/**
- * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for JRun4 AS
+ * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for JRun4 AS
*
* @author Joseph Bissen
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java
new file mode 100644
index 0000000000..db46f082e4
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java
@@ -0,0 +1,63 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.engine.transaction.jta.platform.internal;
+
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
+import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
+import org.hibernate.internal.CoreMessageLogger;
+import org.hibernate.service.spi.ServiceRegistryImplementor;
+
+/**
+ * Standard initiator for the standard {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform}
+ *
+ * @author Steve Ebersole
+ */
+public class JtaPlatformInitiator implements StandardServiceInitiator {
+ public static final JtaPlatformInitiator INSTANCE = new JtaPlatformInitiator();
+
+ private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, JtaPlatformInitiator.class.getName());
+
+ @Override
+ public Class getServiceInitiated() {
+ return JtaPlatform.class;
+ }
+
+ @Override
+ @SuppressWarnings( {"unchecked"})
+ public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
+ final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM );
+ final JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting );
+ if ( platform == null ) {
+ LOG.debugf( " No JtaPlatform was specified, using default [%s]", NoJtaPlatform.class.getName() );
+ return new NoJtaPlatform();
+ }
+ return platform;
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaSynchronizationStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaSynchronizationStrategy.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaSynchronizationStrategy.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaSynchronizationStrategy.java
index f33e461347..d296f0d603 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaSynchronizationStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaSynchronizationStrategy.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.io.Serializable;
import javax.transaction.Synchronization;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/NoJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NoJtaPlatform.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/NoJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NoJtaPlatform.java
index 440674b07b..26c3235c75 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/NoJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NoJtaPlatform.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.Status;
import javax.transaction.Synchronization;
@@ -30,7 +30,7 @@ import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* The non-configured form of JTA platform. This is what is used if none was set up.
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OC4JJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OC4JJtaPlatform.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OC4JJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OC4JJtaPlatform.java
index c21c9c6019..3bdcbdfe96 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OC4JJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OC4JJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
/**
- * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for the OC4J (Oracle) AS.
+ * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for the OC4J (Oracle) AS.
*
* @author Stijn Janssens
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OrionJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OrionJtaPlatform.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OrionJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OrionJtaPlatform.java
index 40028e9539..0e9566d600 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/OrionJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/OrionJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
/**
- * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Orion
+ * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Orion
*
* @author Gavin King
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/ResinJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/ResinJtaPlatform.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/ResinJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/ResinJtaPlatform.java
index b2ad76130e..eaed24a3f9 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/ResinJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/ResinJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
/**
- * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Resin
+ * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Resin
*
* @author Aapo Laakkonen
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SunOneJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SunOneJtaPlatform.java
similarity index 89%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SunOneJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SunOneJtaPlatform.java
index bd962698ec..fd6ebc98ac 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SunOneJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SunOneJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
/**
- * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Sun ONE Application Server 7 and above
+ * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Sun ONE Application Server 7 and above
*
* @author Robert Davidson
* @author Sanjeev Krishnan
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryAccess.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryAccess.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryAccess.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryAccess.java
index 9b4c1d400a..bab04fa19c 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryAccess.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.io.Serializable;
import javax.transaction.TransactionSynchronizationRegistry;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java
index d8af05e484..d4b08df264 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/SynchronizationRegistryBasedSynchronizationStrategy.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.Synchronization;
import javax.transaction.TransactionSynchronizationRegistry;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerAccess.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerAccess.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerAccess.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerAccess.java
index ee4c8ec53a..26c7411743 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerAccess.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.io.Serializable;
import javax.transaction.TransactionManager;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java
index 070fb52ffb..b9e3614138 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/TransactionManagerBasedSynchronizationStrategy.java
@@ -21,12 +21,12 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.Synchronization;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* Implementation of the {@link JtaSynchronizationStrategy} contract based on using a
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java
index ec2e971bae..19a81bdde7 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereExtendedJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereExtendedJtaPlatform.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereJtaPlatform.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereJtaPlatform.java
index 1f8c758f9a..9113045d87 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WebSphereJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WebSphereJtaPlatform.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import java.lang.reflect.Method;
import javax.transaction.TransactionManager;
@@ -30,7 +30,7 @@ import javax.transaction.UserTransaction;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;
/**
* JTA platform implementation for WebSphere (versions 4, 5.0 and 5.1)
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WeblogicJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WeblogicJtaPlatform.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WeblogicJtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WeblogicJtaPlatform.java
index 26bc3a69f5..54c82f8ac1 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/WeblogicJtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/WeblogicJtaPlatform.java
@@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.internal;
+package org.hibernate.engine.transaction.jta.platform.internal;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
/**
- * {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation for Weblogic
+ * {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform} implementation for Weblogic
*
* @author Gavin King
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatform.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java
index 86c56bc843..1bf027f9d3 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatform.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatform.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.spi;
+package org.hibernate.engine.transaction.jta.platform.spi;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatformException.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatformException.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatformException.java
rename to hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatformException.java
index abc7f31d79..28fc1b45da 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/spi/JtaPlatformException.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/spi/JtaPlatformException.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jta.platform.spi;
+package org.hibernate.engine.transaction.jta.platform.spi;
import org.hibernate.HibernateException;
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java
index 22463d4282..a1e8cf2bcd 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/AbstractTransactionImpl.java
@@ -31,7 +31,7 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.TransactionException;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* Abstract support for creating {@link TransactionImplementor transaction} implementations
@@ -98,7 +98,7 @@ public abstract class AbstractTransactionImpl implements TransactionImplementor
/**
* Provide subclasses with convenient access to the configured {@link JtaPlatform}
*
- * @return The {@link org.hibernate.service.jta.platform.spi.JtaPlatform}
+ * @return The {@link org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform}
*/
protected JtaPlatform jtaPlatform() {
return transactionCoordinator().getTransactionContext().getTransactionEnvironment().getJtaPlatform();
diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java
index 65a5f5c622..e3e9e19f5a 100644
--- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java
+++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/spi/TransactionEnvironment.java
@@ -25,7 +25,7 @@ package org.hibernate.engine.transaction.spi;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.stat.spi.StatisticsImplementor;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java
index 0c90f1604e..57a60166ce 100644
--- a/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java
+++ b/hibernate-core/src/main/java/org/hibernate/id/IdentityGenerator.java
@@ -99,7 +99,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
rs = insert.getGeneratedKeys();
return IdentifierGeneratorHelper.getGeneratedIdentity(
rs,
- persister.getIdentifierColumnNames()[0],
+ persister.getRootTableKeyColumnNames()[0],
persister.getIdentifierType()
);
}
@@ -150,7 +150,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
try {
return IdentifierGeneratorHelper.getGeneratedIdentity(
rs,
- persister.getIdentifierColumnNames()[0],
+ persister.getRootTableKeyColumnNames()[0],
persister.getIdentifierType()
);
}
@@ -194,7 +194,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
SessionImplementor session,
ResultSet rs,
Object object) throws SQLException {
- return IdentifierGeneratorHelper.getGeneratedIdentity( rs, null, persister.getIdentifierType() );
+ return IdentifierGeneratorHelper.getGeneratedIdentity( rs, persister.getRootTableKeyColumnNames()[0], persister.getIdentifierType() );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java
index a2180c58f8..6e838cfbe5 100644
--- a/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java
+++ b/hibernate-core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java
@@ -103,7 +103,7 @@ public class SequenceIdentityGenerator
insert.executeUpdate();
return IdentifierGeneratorHelper.getGeneratedIdentity(
insert.getGeneratedKeys(),
- getPersister().getIdentifierColumnNames()[0],
+ getPersister().getRootTableKeyColumnNames()[0],
getPersister().getIdentifierType()
);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java
index 92808e6379..868902fb29 100644
--- a/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/id/factory/internal/MutableIdentifierGeneratorFactoryInitiator.java
@@ -2,14 +2,14 @@ package org.hibernate.id.factory.internal;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
-import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Emmanuel Bernard
*/
-public class MutableIdentifierGeneratorFactoryInitiator implements BasicServiceInitiator {
+public class MutableIdentifierGeneratorFactoryInitiator implements StandardServiceInitiator {
public static final MutableIdentifierGeneratorFactoryInitiator INSTANCE = new MutableIdentifierGeneratorFactoryInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java
index 4ffa634769..b4cd7872d7 100644
--- a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java
@@ -30,7 +30,7 @@ import org.jboss.logging.Logger;
import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java b/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java
index c10282f47c..3891ef4c36 100644
--- a/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java
+++ b/hibernate-core/src/main/java/org/hibernate/integrator/spi/ServiceContributingIntegrator.java
@@ -23,7 +23,7 @@
*/
package org.hibernate.integrator.spi;
-import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
/**
* Additional, optional contract for Integrators that wish to contribute {@link org.hibernate.service.Service services}
@@ -42,5 +42,5 @@ public interface ServiceContributingIntegrator extends Integrator {
*
* @param serviceRegistryBuilder The build to prepare.
*/
- public void prepareServices(ServiceRegistryBuilder serviceRegistryBuilder);
+ public void prepareServices(StandardServiceRegistryBuilder serviceRegistryBuilder);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java
index 432adf922d..3aa6b0d166 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractQueryImpl.java
@@ -49,6 +49,7 @@ import org.hibernate.PropertyNotFoundException;
import org.hibernate.Query;
import org.hibernate.QueryException;
import org.hibernate.Session;
+import org.hibernate.dialect.Dialect;
import org.hibernate.engine.query.spi.ParameterMetadata;
import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.RowSelection;
@@ -65,6 +66,7 @@ import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.SerializableType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
+import org.jboss.logging.Logger;
/**
* Abstract implementation of the Query interface.
@@ -73,6 +75,10 @@ import org.hibernate.type.Type;
* @author Max Andersen
*/
public abstract class AbstractQueryImpl implements Query {
+ private static final CoreMessageLogger log = Logger.getMessageLogger(
+ CoreMessageLogger.class,
+ AbstractQueryImpl.class.getName()
+ );
private static final Object UNSET_PARAMETER = new MarkerObject("");
private static final Object UNSET_TYPE = new MarkerObject("");
@@ -798,6 +804,15 @@ public abstract class AbstractQueryImpl implements Query {
*/
private String expandParameterList(String query, String name, TypedValue typedList, Map namedParamsCopy) {
Collection vals = (Collection) typedList.getValue();
+
+ // HHH-1123
+ // Some DBs limit number of IN expressions. For now, warn...
+ final Dialect dialect = session.getFactory().getDialect();
+ final int inExprLimit = dialect.getInExpressionCountLimit();
+ if ( inExprLimit > 0 && vals.size() > inExprLimit ) {
+ log.tooManyInExpressions( dialect.getClass().getName(), inExprLimit, name, vals.size() );
+ }
+
Type type = typedList.getType();
boolean isJpaPositionalParam = parameterMetadata.getNamedParameterDescriptor( name ).isJpaStyle();
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java
index 72c702266b..77bdddd1b5 100755
--- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSessionImpl.java
@@ -54,9 +54,9 @@ import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.jdbc.WorkExecutor;
import org.hibernate.jdbc.WorkExecutorVisitable;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
-import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.type.Type;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CacheImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/CacheImpl.java
index c4ddd26950..57228f2f92 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/CacheImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/CacheImpl.java
@@ -40,6 +40,7 @@ import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Settings;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.CacheImplementor;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
@@ -47,7 +48,6 @@ import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.InjectService;
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java
index 45e4088496..27ee100055 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/CoreMessageLogger.java
@@ -52,9 +52,9 @@ import org.hibernate.engine.loading.internal.EntityLoadContext;
import org.hibernate.engine.spi.CollectionKey;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.id.IntegralDataTypeHolder;
-import org.hibernate.service.jdbc.dialect.internal.AbstractDialectResolver;
-import org.hibernate.service.jndi.JndiException;
-import org.hibernate.service.jndi.JndiNameException;
+import org.hibernate.engine.jdbc.dialect.internal.AbstractDialectResolver;
+import org.hibernate.engine.jndi.JndiException;
+import org.hibernate.engine.jndi.JndiNameException;
import org.hibernate.type.BasicType;
import org.hibernate.type.SerializationException;
import org.hibernate.type.Type;
@@ -1501,12 +1501,12 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "You should set hibernate.transaction.manager_lookup_class if cache is enabled", id = 426)
void setManagerLookupClass();
- @LogMessage(level = WARN)
- @Message(value = "Using deprecated %s strategy [%s], use newer %s strategy instead [%s]", id = 427)
- void deprecatedTransactionManagerStrategy(String name,
- String transactionManagerStrategy,
- String name2,
- String jtaPlatform);
+// @LogMessage(level = WARN)
+// @Message(value = "Using deprecated %s strategy [%s], use newer %s strategy instead [%s]", id = 427)
+// void deprecatedTransactionManagerStrategy(String name,
+// String transactionManagerStrategy,
+// String name2,
+// String jtaPlatform);
@LogMessage(level = INFO)
@Message(value = "Encountered legacy TransactionManagerLookup specified; convert to newer %s contract specified via %s setting",
@@ -1587,6 +1587,15 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "@CollectionTable and @JoinTable specified on the same attribute. Check %s#%s", id = 446)
String collectionTableAndJoinTableUsedTogether(String entityName, String propertyName);
+ @LogMessage(level = WARN)
+ @Message(
+ value = "Dialect [%s] limits the number of elements in an IN predicate to %s entries. " +
+ "However, the given parameter list [%s] contained %s entries, which will likely cause failures " +
+ "to execute the query in the database",
+ id = 447
+ )
+ void tooManyInExpressions(String dialectName, int limit, String paramName, int size);
+
// moved from hibernate-entitymanager ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java
index 0cc6dad35c..9f0e1030b0 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java
@@ -62,6 +62,7 @@ import org.hibernate.SessionFactoryObserver;
import org.hibernate.StatelessSession;
import org.hibernate.StatelessSessionBuilder;
import org.hibernate.TypeHelper;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cache.internal.CacheDataDescriptionImpl;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.EntityRegion;
@@ -129,13 +130,12 @@ import org.hibernate.persister.entity.Queryable;
import org.hibernate.persister.spi.PersisterFactory;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jndi.spi.JndiService;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.engine.config.spi.ConfigurationService;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jndi.spi.JndiService;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
@@ -167,7 +167,7 @@ import org.hibernate.type.TypeResolver;
* and pooling under the covers. It is crucial that the class is not only thread
* safe, but also highly concurrent. Synchronization must be used extremely sparingly.
*
- * @see org.hibernate.service.jdbc.connections.spi.ConnectionProvider
+ * @see org.hibernate.engine.jdbc.connections.spi.ConnectionProvider
* @see org.hibernate.Session
* @see org.hibernate.hql.spi.QueryTranslator
* @see org.hibernate.persister.entity.EntityPersister
@@ -231,22 +231,19 @@ public final class SessionFactoryImpl
private final EntityNotFoundDelegate entityNotFoundDelegate;
{
- final StrategyInstanceResolver strategyInstanceResolver
- = serviceRegistry.getService( ClassLoaderService.class ).getStrategyInstanceResolver();
-
interceptor = cfg.getInterceptor();
- customEntityDirtinessStrategy = strategyInstanceResolver.resolveDefaultableStrategyInstance(
- cfg.getProperties().get( AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY ),
+ customEntityDirtinessStrategy = serviceRegistry.getService( StrategySelector.class ).resolveDefaultableStrategy(
CustomEntityDirtinessStrategy.class,
+ cfg.getProperties().get( AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY ),
DefaultCustomEntityDirtinessStrategy.INSTANCE
);
currentTenantIdentifierResolver = cfg.getCurrentTenantIdentifierResolver() != null
? cfg.getCurrentTenantIdentifierResolver()
- : strategyInstanceResolver.resolveStrategyInstance(
- cfg.getProperties().get( AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER ),
- CurrentTenantIdentifierResolver.class
+ : serviceRegistry.getService( StrategySelector.class ).resolveStrategy(
+ CurrentTenantIdentifierResolver.class,
+ cfg.getProperties().get( AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER )
);
observer = userObserver;
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java
index 41dcfdeb71..9cdfd99886 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryRegistry.java
@@ -36,9 +36,9 @@ import javax.naming.spi.ObjectFactory;
import org.jboss.logging.Logger;
import org.hibernate.SessionFactory;
-import org.hibernate.service.jndi.JndiException;
-import org.hibernate.service.jndi.JndiNameException;
-import org.hibernate.service.jndi.spi.JndiService;
+import org.hibernate.engine.jndi.JndiException;
+import org.hibernate.engine.jndi.JndiNameException;
+import org.hibernate.engine.jndi.spi.JndiService;
/**
* A registry of all {@link SessionFactory} instances for the same classloader as this class.
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java
index 4abe5f460a..0fdef1d261 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java
@@ -45,6 +45,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.persistence.EntityNotFoundException;
+
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
@@ -64,6 +66,7 @@ import org.hibernate.LockOptions;
import org.hibernate.MappingException;
import org.hibernate.NaturalIdLoadAccess;
import org.hibernate.ObjectDeletedException;
+import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;
import org.hibernate.QueryException;
import org.hibernate.ReplicationMode;
@@ -281,17 +284,10 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
@Override
public void beforeCompletion(TransactionImplementor transaction) {
- if ( isOpen() ) {
- if ( flushBeforeCompletionEnabled ){
- SessionImpl.this.managedFlush();
- }
- getActionQueue().beforeTransactionCompletion();
- }
- else {
- if (actionQueue.hasAfterTransactionActions()){
- LOG.log( Logger.Level.DEBUG, "Session had after transaction actions that were not processed");
- }
+ if ( isOpen() && flushBeforeCompletionEnabled ) {
+ SessionImpl.this.managedFlush();
}
+ beforeTransactionCompletion( transaction );
}
@Override
@@ -2604,7 +2600,16 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
if ( entityId == null ) {
return null;
}
- return this.getIdentifierLoadAccess().load( entityId );
+ try {
+ return this.getIdentifierLoadAccess().load( entityId );
+ }
+ catch (EntityNotFoundException enf) {
+ // OK
+ }
+ catch (ObjectNotFoundException nf) {
+ // OK
+ }
+ return null;
}
}
@@ -2662,7 +2667,16 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
if ( entityId == null ) {
return null;
}
- return this.getIdentifierLoadAccess().load( entityId );
+ try {
+ return this.getIdentifierLoadAccess().load( entityId );
+ }
+ catch (EntityNotFoundException enf) {
+ // OK
+ }
+ catch (ObjectNotFoundException nf) {
+ // OK
+ }
+ return null;
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java
index 28604fa1f3..84f03f07ad 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureCallImpl.java
@@ -53,7 +53,7 @@ import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
+import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.type.DateType;
import org.hibernate.type.ProcedureParameterExtractionAware;
@@ -181,7 +181,8 @@ public class StoredProcedureCallImpl extends AbstractBasicQueryContractImpl impl
throw new QueryException( "Cannot mix named and positional parameters" );
}
if ( typeOfParameters == null ) {
- // protect to only do this check once
+ // protect to only do this check o
+ // nce
final ExtractedDatabaseMetaData databaseMetaData = session().getTransactionCoordinator()
.getJdbcCoordinator()
.getLogicalConnection()
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java
index 2912108abf..31e5e1f77f 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/StoredProcedureOutputsImpl.java
@@ -42,7 +42,7 @@ import org.hibernate.loader.custom.CustomLoader;
import org.hibernate.loader.custom.CustomQuery;
import org.hibernate.loader.custom.Return;
import org.hibernate.loader.custom.sql.SQLQueryReturnProcessor;
-import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
+import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java
index e864ecfea5..e818e84e63 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/TransactionEnvironmentImpl.java
@@ -28,7 +28,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.stat.spi.StatisticsImplementor;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java
index fe2da98d0e..e43aea33b0 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/util/ConfigHelper.java
@@ -40,7 +40,7 @@ import org.hibernate.internal.CoreMessageLogger;
/**
* A simple class to centralize logic needed to locate config files on the system.
*
- * @todo : Update usages to use {@link org.hibernate.service.classloading.spi.ClassLoaderService}
+ * @todo : Update usages to use {@link org.hibernate.boot.registry.classloading.spi.ClassLoaderService}
*
* @author Steve Ebersole
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java
index fdc5191a94..a93b83df39 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/util/jndi/JndiHelper.java
@@ -38,7 +38,7 @@ import org.hibernate.cfg.Environment;
/**
* Helper for dealing with JNDI.
*
- * @deprecated As JNDI access should get routed through {@link org.hibernate.service.jndi.spi.JndiService}
+ * @deprecated As JNDI access should get routed through {@link org.hibernate.engine.jndi.spi.JndiService}
*/
@Deprecated
public final class JndiHelper {
diff --git a/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbConfigurationProcessor.java b/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbConfigurationProcessor.java
index 8add8ef5a0..43201c333a 100644
--- a/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbConfigurationProcessor.java
+++ b/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbConfigurationProcessor.java
@@ -57,7 +57,7 @@ import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.XsdException;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbMappingProcessor.java
index 713b79e42f..ee07026dac 100644
--- a/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbMappingProcessor.java
+++ b/hibernate-core/src/main/java/org/hibernate/jaxb/internal/JaxbMappingProcessor.java
@@ -50,6 +50,8 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
+import org.hibernate.engine.config.spi.ConfigurationService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.hbm.JaxbHibernateMapping;
@@ -57,8 +59,6 @@ import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.XsdException;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java
deleted file mode 100644
index 99810fb517..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java
+++ /dev/null
@@ -1,200 +0,0 @@
-//$Id: HibernateService.java 6100 2005-03-17 10:48:03Z turin42 $
-package org.hibernate.jmx;
-
-import java.util.Map;
-import java.util.Properties;
-import javax.naming.InitialContext;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.HibernateException;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.ExternalSessionFactoryConfig;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.util.jndi.JndiHelper;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-
-
-/**
- * Implementation of HibernateServiceMBean . Creates a
- * SessionFactory and binds it to the specified JNDI name.
- *
- * All mapping documents are loaded as resources by the MBean.
- * @see HibernateServiceMBean
- * @see org.hibernate.SessionFactory
- * @author John Urberg, Gavin King
- * @deprecated See HHH-6190 for details
- */
-@Deprecated
-public class HibernateService extends ExternalSessionFactoryConfig implements HibernateServiceMBean {
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, HibernateService.class.getName());
-
- private String boundName;
- private Properties properties = new Properties();
-
- @Override
- public void start() throws HibernateException {
- boundName = getJndiName();
- try {
- buildSessionFactory();
- }
- catch (HibernateException he) {
- LOG.unableToBuildSessionFactoryUsingMBeanClasspath(he.getMessage());
- LOG.debug("Error was", he);
- new SessionFactoryStub(this);
- }
- }
-
- @Override
- public void stop() {
- LOG.stoppingService();
- try {
- InitialContext context = JndiHelper.getInitialContext( buildProperties() );
- ( (SessionFactory) context.lookup(boundName) ).close();
- //context.unbind(boundName);
- }
- catch (Exception e) {
- LOG.unableToStopHibernateService(e);
- }
- }
-
- SessionFactory buildSessionFactory() throws HibernateException {
- LOG.startingServiceAtJndiName( boundName );
- LOG.serviceProperties( properties );
- return buildConfiguration().buildSessionFactory(
- new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry()
- );
- }
-
- @Override
- protected Map getExtraProperties() {
- return properties;
- }
-
- @Override
- public String getTransactionStrategy() {
- return getProperty(Environment.TRANSACTION_STRATEGY);
- }
-
- @Override
- public void setTransactionStrategy(String txnStrategy) {
- setProperty(Environment.TRANSACTION_STRATEGY, txnStrategy);
- }
-
- @Override
- public String getUserTransactionName() {
- return getProperty(Environment.USER_TRANSACTION);
- }
-
- @Override
- public void setUserTransactionName(String utName) {
- setProperty(Environment.USER_TRANSACTION, utName);
- }
-
- @Override
- public String getJtaPlatformName() {
- return getProperty( AvailableSettings.JTA_PLATFORM );
- }
-
- @Override
- public void setJtaPlatformName(String name) {
- setProperty( AvailableSettings.JTA_PLATFORM, name );
- }
-
- @Override
- public String getPropertyList() {
- return buildProperties().toString();
- }
-
- @Override
- public String getProperty(String property) {
- return properties.getProperty(property);
- }
-
- @Override
- public void setProperty(String property, String value) {
- properties.setProperty(property, value);
- }
-
- @Override
- public void dropSchema() {
- new SchemaExport( buildConfiguration() ).drop(false, true);
- }
-
- @Override
- public void createSchema() {
- new SchemaExport( buildConfiguration() ).create(false, true);
- }
-
- public String getName() {
- return getProperty(Environment.SESSION_FACTORY_NAME);
- }
-
- @Override
- public String getDatasource() {
- return getProperty(Environment.DATASOURCE);
- }
-
- @Override
- public void setDatasource(String datasource) {
- setProperty(Environment.DATASOURCE, datasource);
- }
-
- @Override
- public String getJndiName() {
- return getProperty(Environment.SESSION_FACTORY_NAME);
- }
-
- @Override
- public void setJndiName(String jndiName) {
- setProperty(Environment.SESSION_FACTORY_NAME, jndiName);
- }
-
- @Override
- public String getUserName() {
- return getProperty(Environment.USER);
- }
-
- @Override
- public void setUserName(String userName) {
- setProperty(Environment.USER, userName);
- }
-
- @Override
- public String getPassword() {
- return getProperty(Environment.PASS);
- }
-
- @Override
- public void setPassword(String password) {
- setProperty(Environment.PASS, password);
- }
-
- @Override
- public void setFlushBeforeCompletionEnabled(String enabled) {
- setProperty(Environment.FLUSH_BEFORE_COMPLETION, enabled);
- }
-
- @Override
- public String getFlushBeforeCompletionEnabled() {
- return getProperty(Environment.FLUSH_BEFORE_COMPLETION);
- }
-
- @Override
- public void setAutoCloseSessionEnabled(String enabled) {
- setProperty(Environment.AUTO_CLOSE_SESSION, enabled);
- }
-
- @Override
- public String getAutoCloseSessionEnabled() {
- return getProperty(Environment.AUTO_CLOSE_SESSION);
- }
-
- public Properties getProperties() {
- return buildProperties();
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java
deleted file mode 100644
index 2d2913d7a3..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java
+++ /dev/null
@@ -1,337 +0,0 @@
-//$Id: HibernateServiceMBean.java 10860 2006-11-22 00:02:55Z steve.ebersole@jboss.com $
-package org.hibernate.jmx;
-import org.hibernate.HibernateException;
-
-/**
- * Hibernate JMX Management API
- * @see HibernateService
- * @author John Urberg, Gavin King
- * @deprecated See HHH-6190 for details
- */
-@Deprecated
-public interface HibernateServiceMBean {
-
- /**
- * The Hibernate mapping files (might be overridden by subclasses
- * that want to specify the mapping files by some other mechanism)
- * @return String
- */
- public String getMapResources();
- /**
- * Specify the Hibernate mapping files
- * @param mappingFiles
- */
- public void setMapResources(String mappingFiles);
- /**
- * Add a mapping file
- * @param mapResource
- */
- public void addMapResource(String mapResource);
-
- /**
- * Set a property
- * @param property the property name
- * @param value the property value
- */
- public void setProperty(String property, String value);
-
- /**
- * Get a property
- * @param property the property name
- * @return the property value
- */
- public String getProperty(String property);
-
- /**
- * Display the properties
- * @return a list of property names and values
- */
- public String getPropertyList();
-
- /**
- * The JNDI name of the datasource to use in this SessionFactory
- * @return String
- */
- public String getDatasource();
- /**
- * Set the JNDI name of the datasource to use in this SessionFactory
- * @param datasource
- */
- public void setDatasource(String datasource);
-
- /**
- * Log into the database with this name
- * @return String
- */
- public String getUserName();
- /**
- * Log into the database with this name
- * @param userName
- */
- public void setUserName(String userName);
-
- /**
- * Log into the database with this password
- * @return String
- */
- public String getPassword();
- /**
- * Log into the database with this password
- * @param password
- */
- public void setPassword(String password);
-
- /**
- * The JNDI name of the dialect class to use in this SessionFactory
- * @return String
- */
- public String getDialect();
- /**
- * The name of the dialect class to use in this SessionFactory
- * @param dialect fully qualified class name of Dialect subclass
- * @see org.hibernate.dialect.Dialect
- */
- public void setDialect(String dialect);
-
- /**
- * The JNDI name to bind to the SessionFactory
- * @return String
- */
- public String getJndiName();
- /**
- * The JNDI name to bind to the SessionFactory
- * @param jndiName
- */
- public void setJndiName(String jndiName);
-
- /**
- * The fully qualified class name of the Hibernate {@link org.hibernate.engine.transaction.spi.TransactionFactory}
- * implementation to use
- *
- * @return the class name
- */
- public String getTransactionStrategy();
-
- /**
- * Set the fully qualified class name of the Hibernate {@link org.hibernate.engine.transaction.spi.TransactionFactory}
- * implementation to use.
- *
- * @param txnStrategy the class name
- */
- public void setTransactionStrategy(String txnStrategy);
-
- /**
- * The JNDI name of the JTA UserTransaction object (used only be JtaTransaction ).
- * @return the JNDI name
- * @see org.hibernate.engine.transaction.internal.jta.JtaTransaction
- */
- public String getUserTransactionName();
- /**
- * Set the JNDI name of the JTA UserTransaction object (used only by JtaTransaction ).
- * @param utName the JNDI name
- * @see org.hibernate.engine.transaction.internal.jta.JtaTransaction
- */
- public void setUserTransactionName(String utName);
-
- /**
- * Get the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use.
- *
- * @return The name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use.
- */
- public String getJtaPlatformName();
-
- /**
- * Sets the name of the {@link org.hibernate.service.jta.platform.spi.JtaPlatform} implementation to use.
- *
- * @param name The implementation class name.
- */
- public void setJtaPlatformName(String name);
-
- /**
- * Is SQL logging enabled?
- */
- public String getShowSqlEnabled();
- /**
- * Enable logging of SQL to console
- */
- public void setShowSqlEnabled(String showSql);
- /**
- * Get the maximum outer join fetch depth
- */
- public String getMaximumFetchDepth();
- /**
- * Set the maximum outer join fetch depth
- */
- public void setMaximumFetchDepth(String fetchDepth);
- /**
- * Get the maximum JDBC batch size
- */
- public String getJdbcBatchSize();
- /**
- * Set the maximum JDBC batch size
- */
- public void setJdbcBatchSize(String batchSize);
- /**
- * Get the JDBC fetch size
- */
- public String getJdbcFetchSize();
- /**
- * Set the JDBC fetch size
- */
- public void setJdbcFetchSize(String fetchSize);
- /**
- * Get the query language substitutions
- */
- public String getQuerySubstitutions();
- /**
- * Set the query language substitutions
- */
- public void setQuerySubstitutions(String querySubstitutions);
- /**
- * Get the default schema
- */
- public String getDefaultSchema();
- /**
- * Set the default schema
- */
- public void setDefaultSchema(String schema);
- /**
- * Get the default catalog
- */
- public String getDefaultCatalog();
- /**
- * Set the default catalog
- */
- public void setDefaultCatalog(String catalog);
- /**
- * Is use of scrollable resultsets enabled?
- */
- public String getJdbcScrollableResultSetEnabled();
- /**
- * Enable or disable the use of scrollable resultsets
- */
- public void setJdbcScrollableResultSetEnabled(String enabled);
- /**
- * Is use of JDBC3 getGeneratedKeys() enabled?
- */
- public String getGetGeneratedKeysEnabled();
- /**
- * Enable or disable the use getGeneratedKeys()
- */
- public void setGetGeneratedKeysEnabled(String enabled);
- /**
- * Get the second-level cache provider class name
- */
- public String getCacheRegionFactory();
- /**
- * Set the second-level cache provider class name
- */
- public void setCacheRegionFactory(String cacheRegionFactory);
- /**
- * For cache providers which support this setting, get the
- * provider's specific configuration resource.
- */
- public String getCacheProviderConfig();
- /**
- * For cache providers which support this setting, specify the
- * provider's specific configuration resource.
- */
- public void setCacheProviderConfig(String cacheProviderConfig);
- /**
- * Is the query cache enabled?
- */
- public String getQueryCacheEnabled();
- /**
- * Enable or disable the query cache
- */
- public void setQueryCacheEnabled(String enabled);
- /**
- * Is the second-level cache enabled?
- */
- public String getSecondLevelCacheEnabled();
- /**
- * Enable or disable the second-level cache
- */
- public void setSecondLevelCacheEnabled(String enabled);
- /**
- * Get the cache region prefix
- */
- public String getCacheRegionPrefix();
- /**
- * Set the cache region prefix
- */
- public void setCacheRegionPrefix(String prefix);
- /**
- * Is the second-level cache optimized for miminal puts?
- */
- public String getMinimalPutsEnabled();
- /**
- * Enable or disable optimization of second-level cache
- * for minimal puts
- */
- public void setMinimalPutsEnabled(String enabled);
- /**
- * Are SQL comments enabled?
- */
- public String getCommentsEnabled();
- /**
- * Enable or disable the inclusion of comments in
- * generated SQL
- */
- public void setCommentsEnabled(String enabled);
- /**
- * Is JDBC batch update for versioned entities enabled?
- */
- public String getBatchVersionedDataEnabled();
- /**
- * Enable or disable the use of batch updates for
- * versioned entities
- */
- public void setBatchVersionedDataEnabled(String enabled);
-
- /**
- * Enable automatic flushing of the Session when JTA transaction ends.
- */
- public void setFlushBeforeCompletionEnabled(String enabled);
- /**
- * Is automatic Session flusing enabled?
- */
- public String getFlushBeforeCompletionEnabled();
-
- /**
- * Enable automatic closing of Session when JTA transaction ends.
- */
- public void setAutoCloseSessionEnabled(String enabled);
- /**
- * Is automatic Session closing enabled?
- */
- public String getAutoCloseSessionEnabled();
-
- /**
- * Export the CREATE DDL to the database
- * @throws HibernateException
- */
- public void createSchema() throws HibernateException;
- /**
- * Export the DROP DDL to the database
- * @throws HibernateException
- */
- public void dropSchema() throws HibernateException;
-
-
- /**
- * Create the SessionFactory and bind to the jndi name on startup
- */
- public void start() throws HibernateException;
- /**
- * Unbind the SessionFactory or stub from JNDI
- */
- public void stop();
-
-}
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java b/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java
deleted file mode 100644
index 837aa39be0..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/jmx/SessionFactoryStub.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.jmx;
-
-import java.io.InvalidObjectException;
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-import java.sql.Connection;
-import java.util.Map;
-import java.util.Set;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.Cache;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionBuilder;
-import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
-import org.hibernate.StatelessSessionBuilder;
-import org.hibernate.TypeHelper;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.engine.spi.FilterDefinition;
-import org.hibernate.id.IdentifierGenerator;
-import org.hibernate.id.UUIDGenerator;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.SessionFactoryRegistry;
-import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.metadata.CollectionMetadata;
-import org.hibernate.service.jndi.internal.JndiServiceImpl;
-import org.hibernate.stat.Statistics;
-
-/**
- * A flyweight for SessionFactory . If the MBean itself does not
- * have classpath to the persistent classes, then a stub will be registered
- * with JNDI and the actual SessionFactoryImpl built upon first
- * access.
- *
- * @author Gavin King
- *
- * @deprecated See HHH-6190 for details
- */
-@Deprecated
-@SuppressWarnings( {"deprecation"})
-public class SessionFactoryStub implements SessionFactory {
- private static final IdentifierGenerator UUID_GENERATOR = UUIDGenerator.buildSessionFactoryUniqueIdentifierGenerator();
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, SessionFactoryStub.class.getName());
-
- private transient SessionFactory impl;
- private transient HibernateService service;
- private String uuid;
- private String name;
-
- SessionFactoryStub(HibernateService service) {
- this.service = service;
- this.name = service.getJndiName();
- try {
- uuid = (String) UUID_GENERATOR.generate(null, null);
- }
- catch (Exception e) {
- throw new AssertionFailure("Could not generate UUID");
- }
-
- SessionFactoryRegistry.INSTANCE.addSessionFactory(
- uuid,
- name,
- ConfigurationHelper.getBoolean(
- AvailableSettings.SESSION_FACTORY_NAME_IS_JNDI,
- service.getProperties(),
- true
- ),
- this,
- new JndiServiceImpl( service.getProperties() )
- );
- }
-
- @Override
- public SessionFactoryOptions getSessionFactoryOptions() {
- return impl.getSessionFactoryOptions();
- }
-
- @Override
- public SessionBuilder withOptions() {
- return getImpl().withOptions();
- }
-
- public Session openSession() throws HibernateException {
- return getImpl().openSession();
- }
-
- public Session getCurrentSession() {
- return getImpl().getCurrentSession();
- }
-
- private synchronized SessionFactory getImpl() {
- if (impl==null) impl = service.buildSessionFactory();
- return impl;
- }
-
- //readResolveObject
- private Object readResolve() throws ObjectStreamException {
- // look for the instance by uuid
- Object result = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid ) ;
- if ( result == null ) {
- // in case we were deserialized in a different JVM, look for an instance with the same name
- // (alternatively we could do an actual JNDI lookup here....)
- result = SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( name );
- if ( result == null ) {
- throw new InvalidObjectException( "Could not find a SessionFactory [uuid=" + uuid + ",name=" + name + "]" );
- }
- LOG.debug("Resolved stub SessionFactory by name");
- }
- else {
- LOG.debug("Resolved stub SessionFactory by UUID");
- }
- return result;
- }
-
- /**
- * @see javax.naming.Referenceable#getReference()
- */
- @Override
- public Reference getReference() throws NamingException {
- return new Reference(
- SessionFactoryStub.class.getName(),
- new StringRefAddr("uuid", uuid),
- SessionFactoryRegistry.ObjectFactoryImpl.class.getName(),
- null
- );
- }
-
- public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException {
- return getImpl().getClassMetadata(persistentClass);
- }
-
- public ClassMetadata getClassMetadata(String entityName)
- throws HibernateException {
- return getImpl().getClassMetadata(entityName);
- }
-
- public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException {
- return getImpl().getCollectionMetadata(roleName);
- }
-
- public Map getAllClassMetadata() throws HibernateException {
- return getImpl().getAllClassMetadata();
- }
-
- public Map getAllCollectionMetadata() throws HibernateException {
- return getImpl().getAllCollectionMetadata();
- }
-
- public void close() throws HibernateException {
- }
-
- public boolean isClosed() {
- return false;
- }
-
- public Cache getCache() {
- return getImpl().getCache();
- }
-
- public void evict(Class persistentClass, Serializable id)
- throws HibernateException {
- getImpl().evict(persistentClass, id);
- }
-
- public void evict(Class persistentClass) throws HibernateException {
- getImpl().evict(persistentClass);
- }
-
- public void evictEntity(String entityName, Serializable id)
- throws HibernateException {
- getImpl().evictEntity(entityName, id);
- }
-
- public void evictEntity(String entityName) throws HibernateException {
- getImpl().evictEntity(entityName);
- }
-
- public void evictCollection(String roleName, Serializable id)
- throws HibernateException {
- getImpl().evictCollection(roleName, id);
- }
-
- public void evictCollection(String roleName) throws HibernateException {
- getImpl().evictCollection(roleName);
- }
-
- public void evictQueries() throws HibernateException {
- getImpl().evictQueries();
- }
-
- public void evictQueries(String cacheRegion) throws HibernateException {
- getImpl().evictQueries(cacheRegion);
- }
-
- public Statistics getStatistics() {
- return getImpl().getStatistics();
- }
-
- @Override
- public StatelessSessionBuilder withStatelessOptions() {
- return getImpl().withStatelessOptions();
- }
-
- public StatelessSession openStatelessSession() {
- return getImpl().openStatelessSession();
- }
-
- public StatelessSession openStatelessSession(Connection conn) {
- return getImpl().openStatelessSession(conn);
- }
-
- public Set getDefinedFilterNames() {
- return getImpl().getDefinedFilterNames();
- }
-
- public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
- return getImpl().getFilterDefinition( filterName );
- }
-
- public boolean containsFetchProfileDefinition(String name) {
- return getImpl().containsFetchProfileDefinition( name );
- }
-
- public TypeHelper getTypeHelper() {
- return getImpl().getTypeHelper();
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java b/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java
deleted file mode 100644
index 2895997b41..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsService.java
+++ /dev/null
@@ -1,367 +0,0 @@
-package org.hibernate.jmx;
-
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.SessionFactoryRegistry;
-import org.hibernate.stat.CollectionStatistics;
-import org.hibernate.stat.EntityStatistics;
-import org.hibernate.stat.NaturalIdCacheStatistics;
-import org.hibernate.stat.QueryStatistics;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-import org.hibernate.stat.Statistics;
-import org.hibernate.stat.internal.ConcurrentStatisticsImpl;
-
-/**
- * JMX service for Hibernate statistics
- *
- * Register this MBean in your JMX server for a specific session factory
- *
- * //build the ObjectName you want
- * Hashtable tb = new Hashtable();
- * tb.put("type", "statistics");
- * tb.put("sessionFactory", "myFinancialApp");
- * ObjectName on = new ObjectName("hibernate", tb);
- * StatisticsService stats = new StatisticsService();
- * stats.setSessionFactory(sessionFactory);
- * server.registerMBean(stats, on);
- *
- * And call the MBean the way you want
- *
- * Register this MBean in your JMX server with no specific session factory
- *
- * //build the ObjectName you want
- * Hashtable tb = new Hashtable();
- * tb.put("type", "statistics");
- * tb.put("sessionFactory", "myFinancialApp");
- * ObjectName on = new ObjectName("hibernate", tb);
- * StatisticsService stats = new StatisticsService();
- * server.registerMBean(stats, on);
- *
- * And call the MBean by providing the SessionFactoryJNDIName
first.
- * Then the session factory will be retrieved from JNDI and the statistics
- * loaded.
- *
- * @author Emmanuel Bernard
- * @deprecated See HHH-6190 for details
- */
-@Deprecated
-public class StatisticsService implements StatisticsServiceMBean {
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, StatisticsService.class.getName() );
- //TODO: We probably should have a StatisticsNotPublishedException, to make it clean
-
- SessionFactory sf;
- String sfJNDIName;
- Statistics stats = new ConcurrentStatisticsImpl();
-
- /**
- * @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String)
- */
- public void setSessionFactoryJNDIName(String sfJNDIName) {
- this.sfJNDIName = sfJNDIName;
- try {
- final SessionFactory sessionFactory;
- final Object jndiValue = new InitialContext().lookup( sfJNDIName );
- if ( jndiValue instanceof Reference ) {
- final String uuid = (String) ( (Reference) jndiValue ).get( 0 ).getContent();
- sessionFactory = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid );
- }
- else {
- sessionFactory = (SessionFactory) jndiValue;
- }
- setSessionFactory( sessionFactory );
- }
- catch (NameNotFoundException e) {
- LOG.noSessionFactoryWithJndiName( sfJNDIName, e );
- setSessionFactory(null);
- }
- catch (NamingException e) {
- LOG.unableToAccessSessionFactory( sfJNDIName, e );
- setSessionFactory(null);
- }
- catch (ClassCastException e) {
- LOG.jndiNameDoesNotHandleSessionFactoryReference( sfJNDIName, e );
- setSessionFactory(null);
- }
- }
-
- /**
- * Useful to init this MBean wo a JNDI session factory name
- *
- * @param sf session factory to register
- */
- public void setSessionFactory(SessionFactory sf) {
- this.sf = sf;
- if (sf == null) {
- stats = new ConcurrentStatisticsImpl();
- }
- else {
- stats = sf.getStatistics();
- }
-
- }
- /**
- * @see StatisticsServiceMBean#clear()
- */
- public void clear() {
- stats.clear();
- }
- /**
- * @see StatisticsServiceMBean#getEntityStatistics(java.lang.String)
- */
- public EntityStatistics getEntityStatistics(String entityName) {
- return stats.getEntityStatistics(entityName);
- }
- /**
- * @see StatisticsServiceMBean#getCollectionStatistics(java.lang.String)
- */
- public CollectionStatistics getCollectionStatistics(String role) {
- return stats.getCollectionStatistics(role);
- }
- /**
- * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String)
- */
- public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
- return stats.getSecondLevelCacheStatistics(regionName);
- }
- /**
- * @see StatisticsServiceMBean#getQueryStatistics(java.lang.String)
- */
- public QueryStatistics getQueryStatistics(String hql) {
- return stats.getQueryStatistics(hql);
- }
- /**
- * @see StatisticsServiceMBean#getEntityDeleteCount()
- */
- public long getEntityDeleteCount() {
- return stats.getEntityDeleteCount();
- }
- /**
- * @see StatisticsServiceMBean#getEntityInsertCount()
- */
- public long getEntityInsertCount() {
- return stats.getEntityInsertCount();
- }
- /**
- * @see StatisticsServiceMBean#getEntityLoadCount()
- */
- public long getEntityLoadCount() {
- return stats.getEntityLoadCount();
- }
- /**
- * @see StatisticsServiceMBean#getEntityFetchCount()
- */
- public long getEntityFetchCount() {
- return stats.getEntityFetchCount();
- }
- /**
- * @see StatisticsServiceMBean#getEntityUpdateCount()
- */
- public long getEntityUpdateCount() {
- return stats.getEntityUpdateCount();
- }
- /**
- * @see StatisticsServiceMBean#getQueryExecutionCount()
- */
- public long getQueryExecutionCount() {
- return stats.getQueryExecutionCount();
- }
- public long getQueryCacheHitCount() {
- return stats.getQueryCacheHitCount();
- }
- public long getQueryExecutionMaxTime() {
- return stats.getQueryExecutionMaxTime();
- }
- public long getQueryCacheMissCount() {
- return stats.getQueryCacheMissCount();
- }
- public long getQueryCachePutCount() {
- return stats.getQueryCachePutCount();
- }
-
- public long getUpdateTimestampsCacheHitCount() {
- return stats.getUpdateTimestampsCacheHitCount();
- }
-
- public long getUpdateTimestampsCacheMissCount() {
- return stats.getUpdateTimestampsCacheMissCount();
- }
-
- public long getUpdateTimestampsCachePutCount() {
- return stats.getUpdateTimestampsCachePutCount();
- }
-
- /**
- * @see StatisticsServiceMBean#getFlushCount()
- */
- public long getFlushCount() {
- return stats.getFlushCount();
- }
- /**
- * @see StatisticsServiceMBean#getConnectCount()
- */
- public long getConnectCount() {
- return stats.getConnectCount();
- }
- /**
- * @see StatisticsServiceMBean#getSecondLevelCacheHitCount()
- */
- public long getSecondLevelCacheHitCount() {
- return stats.getSecondLevelCacheHitCount();
- }
- /**
- * @see StatisticsServiceMBean#getSecondLevelCacheMissCount()
- */
- public long getSecondLevelCacheMissCount() {
- return stats.getSecondLevelCacheMissCount();
- }
- /**
- * @see StatisticsServiceMBean#getSecondLevelCachePutCount()
- */
- public long getSecondLevelCachePutCount() {
- return stats.getSecondLevelCachePutCount();
- }
-
- public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String regionName) {
- return stats.getNaturalIdCacheStatistics( regionName );
- }
-
- public long getNaturalIdCacheHitCount() {
- return stats.getNaturalIdCacheHitCount();
- }
-
- public long getNaturalIdCacheMissCount() {
- return stats.getNaturalIdCacheMissCount();
- }
-
- public long getNaturalIdCachePutCount() {
- return stats.getNaturalIdCachePutCount();
- }
-
- @Override
- public long getNaturalIdQueryExecutionCount() {
- return stats.getNaturalIdQueryExecutionCount();
- }
-
- @Override
- public long getNaturalIdQueryExecutionMaxTime() {
- return stats.getNaturalIdQueryExecutionMaxTime();
- }
-
- @Override
- public String getNaturalIdQueryExecutionMaxTimeRegion() {
- return stats.getNaturalIdQueryExecutionMaxTimeRegion();
- }
-
- /**
- * @see StatisticsServiceMBean#getSessionCloseCount()
- */
- public long getSessionCloseCount() {
- return stats.getSessionCloseCount();
- }
- /**
- * @see StatisticsServiceMBean#getSessionOpenCount()
- */
- public long getSessionOpenCount() {
- return stats.getSessionOpenCount();
- }
- /**
- * @see StatisticsServiceMBean#getCollectionLoadCount()
- */
- public long getCollectionLoadCount() {
- return stats.getCollectionLoadCount();
- }
- /**
- * @see StatisticsServiceMBean#getCollectionFetchCount()
- */
- public long getCollectionFetchCount() {
- return stats.getCollectionFetchCount();
- }
- /**
- * @see StatisticsServiceMBean#getCollectionUpdateCount()
- */
- public long getCollectionUpdateCount() {
- return stats.getCollectionUpdateCount();
- }
- /**
- * @see StatisticsServiceMBean#getCollectionRemoveCount()
- */
- public long getCollectionRemoveCount() {
- return stats.getCollectionRemoveCount();
- }
- /**
- * @see StatisticsServiceMBean#getCollectionRecreateCount()
- */
- public long getCollectionRecreateCount() {
- return stats.getCollectionRecreateCount();
- }
- /**
- * @see StatisticsServiceMBean#getStartTime()
- */
- public long getStartTime() {
- return stats.getStartTime();
- }
-
- /**
- * @see StatisticsServiceMBean#isStatisticsEnabled()
- */
- public boolean isStatisticsEnabled() {
- return stats.isStatisticsEnabled();
- }
-
- /**
- * @see StatisticsServiceMBean#setStatisticsEnabled(boolean)
- */
- public void setStatisticsEnabled(boolean enable) {
- stats.setStatisticsEnabled(enable);
- }
-
- public void logSummary() {
- stats.logSummary();
- }
-
- public String[] getCollectionRoleNames() {
- return stats.getCollectionRoleNames();
- }
-
- public String[] getEntityNames() {
- return stats.getEntityNames();
- }
-
- public String[] getQueries() {
- return stats.getQueries();
- }
-
- public String[] getSecondLevelCacheRegionNames() {
- return stats.getSecondLevelCacheRegionNames();
- }
-
- public long getSuccessfulTransactionCount() {
- return stats.getSuccessfulTransactionCount();
- }
- public long getTransactionCount() {
- return stats.getTransactionCount();
- }
-
- public long getCloseStatementCount() {
- return stats.getCloseStatementCount();
- }
- public long getPrepareStatementCount() {
- return stats.getPrepareStatementCount();
- }
-
- public long getOptimisticFailureCount() {
- return stats.getOptimisticFailureCount();
- }
-
- public String getQueryExecutionMaxTimeQueryString() {
- return stats.getQueryExecutionMaxTimeQueryString();
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java b/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java
deleted file mode 100644
index 63d5514722..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/jmx/StatisticsServiceMBean.java
+++ /dev/null
@@ -1,20 +0,0 @@
-//$Id: StatisticsServiceMBean.java 4332 2004-08-15 12:55:28Z oneovthafew $
-package org.hibernate.jmx;
-import org.hibernate.stat.Statistics;
-
-/**
- * MBean exposing Session Factory statistics
- *
- * @see org.hibernate.stat.Statistics
- * @author Emmanuel Bernard
- * @deprecated See HHH-6190 for details
- */
-@Deprecated
-public interface StatisticsServiceMBean extends Statistics {
- /**
- * Publish the statistics of a session factory bound to
- * the default JNDI context
- * @param sfJNDIName session factory jndi name
- */
- public abstract void setSessionFactoryJNDIName(String sfJNDIName);
-}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/DisabledJmxServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/DisabledJmxServiceImpl.java
similarity index 94%
rename from hibernate-core/src/main/java/org/hibernate/service/jmx/internal/DisabledJmxServiceImpl.java
rename to hibernate-core/src/main/java/org/hibernate/jmx/internal/DisabledJmxServiceImpl.java
index d9a1efe228..943a9a6769 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/DisabledJmxServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/DisabledJmxServiceImpl.java
@@ -21,10 +21,10 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jmx.internal;
+package org.hibernate.jmx.internal;
import javax.management.ObjectName;
-import org.hibernate.service.jmx.spi.JmxService;
+import org.hibernate.jmx.spi.JmxService;
import org.hibernate.service.spi.Manageable;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceImpl.java
rename to hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java
index 4ba6ca1ba2..384f56e6ec 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceImpl.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jmx.internal;
+package org.hibernate.jmx.internal;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Map;
@@ -38,7 +38,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.Service;
-import org.hibernate.service.jmx.spi.JmxService;
+import org.hibernate.jmx.spi.JmxService;
import org.hibernate.service.spi.Manageable;
import org.hibernate.service.spi.Stoppable;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java
similarity index 88%
rename from hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceInitiator.java
rename to hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java
index 1d2cc97eb9..e3c7b51a45 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jmx/internal/JmxServiceInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/jmx/internal/JmxServiceInitiator.java
@@ -21,14 +21,14 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jmx.internal;
+package org.hibernate.jmx.internal;
import java.util.Map;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.service.jmx.spi.JmxService;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.jmx.spi.JmxService;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
@@ -36,7 +36,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
*
* @author Steve Ebersole
*/
-public class JmxServiceInitiator implements BasicServiceInitiator {
+public class JmxServiceInitiator implements StandardServiceInitiator {
public static final JmxServiceInitiator INSTANCE = new JmxServiceInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/package.html b/hibernate-core/src/main/java/org/hibernate/jmx/package.html
deleted file mode 100755
index 66827f9090..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/jmx/package.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
- This package exposes a Hibernate instance via JMX.
-
-
- HibernateService allows configuration and management
- of the Hibernate runtime. StatisticsService
- reports information that might be useful for performance
- tuning.
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jmx/spi/JmxService.java b/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/service/jmx/spi/JmxService.java
rename to hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java
index 629cf8faec..96a52d4730 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jmx/spi/JmxService.java
+++ b/hibernate-core/src/main/java/org/hibernate/jmx/spi/JmxService.java
@@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
-package org.hibernate.service.jmx.spi;
+package org.hibernate.jmx.spi;
import javax.management.ObjectName;
diff --git a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
index 166a2a6f5d..1b009ce860 100755
--- a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
+++ b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
@@ -155,7 +155,15 @@ public class CriteriaJoinWalker extends AbstractEntityJoinWalker {
if ( isDefaultFetchMode( fetchMode ) ) {
if ( persister != null ) {
if ( isJoinFetchEnabledByProfile( persister, path, propertyNumber ) ) {
- resolvedJoinType = getJoinType( nullable, currentDepth );
+ if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) {
+ resolvedJoinType = JoinType.NONE;
+ }
+ else if ( isTooDeep(currentDepth) || ( associationType.isCollectionType() && isTooManyCollections() ) ) {
+ resolvedJoinType = JoinType.NONE;
+ }
+ else {
+ resolvedJoinType = getJoinType( nullable, currentDepth );
+ }
}
else {
resolvedJoinType = super.getJoinType(
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java
index 0de1a5745f..5f20d9b273 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java
@@ -55,7 +55,7 @@ import org.hibernate.metamodel.internal.source.annotations.xml.mocker.EntityMapp
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MappingNotFoundException;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* Entry point into working with sources of metadata information ({@code hbm.xml}, annotations). Tell Hibernate
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java
index cd0e904028..72be827dc1 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/Binder.java
@@ -42,6 +42,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.engine.FetchTiming;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.id.EntityIdentifierNature;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.IdentityGenerator;
@@ -144,7 +145,6 @@ import org.hibernate.metamodel.spi.source.UniqueConstraintSource;
import org.hibernate.metamodel.spi.source.VersionAttributeSource;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.tuple.component.ComponentMetamodel;
import org.hibernate.tuple.entity.EntityTuplizer;
import org.hibernate.type.ComponentType;
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataBuilderImpl.java
index 35b1419607..8b6cbbc8cd 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataBuilderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataBuilderImpl.java
@@ -29,6 +29,7 @@ import org.jboss.jandex.IndexView;
import org.xml.sax.EntityResolver;
import org.hibernate.MultiTenancyStrategy;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.EJB3DTDEntityResolver;
@@ -40,8 +41,7 @@ import org.hibernate.metamodel.MetadataSourceProcessingOrder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.MetadataSourcesContributor;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java
index db0e26f743..a801c00ec7 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java
@@ -83,7 +83,7 @@ import org.hibernate.metamodel.spi.source.MappingDefaults;
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
import org.hibernate.metamodel.spi.source.TypeDescriptorSource;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.type.TypeResolver;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/SessionFactoryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/SessionFactoryBuilderImpl.java
index 8b9b56dd25..9815c44822 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/SessionFactoryBuilderImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/SessionFactoryBuilderImpl.java
@@ -36,17 +36,16 @@ import org.hibernate.Interceptor;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.internal.DefaultCustomEntityDirtinessStrategy;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.metamodel.SessionFactoryBuilder;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
-import org.hibernate.service.config.spi.ConfigurationService;
/**
* @author Gail Badner
@@ -111,14 +110,13 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilder {
private EntityNotFoundDelegate entityNotFoundDelegate;
public SessionFactoryOptionsImpl(ServiceRegistry serviceRegistry) {
- final StrategyInstanceResolver strategyInstanceResolver
- = serviceRegistry.getService( ClassLoaderService.class ).getStrategyInstanceResolver();
-
final Map configurationSettings = serviceRegistry.getService( ConfigurationService.class ).getSettings();
- this.interceptor = strategyInstanceResolver.resolveDefaultableStrategyInstance(
- configurationSettings.get( AvailableSettings.INTERCEPTOR ),
+ final StrategySelector strategySelector = serviceRegistry.getService( StrategySelector.class );
+
+ this.interceptor = strategySelector.resolveDefaultableStrategy(
Interceptor.class,
+ configurationSettings.get( AvailableSettings.INTERCEPTOR ),
EmptyInterceptor.INSTANCE
);
@@ -129,15 +127,15 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilder {
}
};
- this.customEntityDirtinessStrategy = strategyInstanceResolver.resolveDefaultableStrategyInstance(
- configurationSettings.get( AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY ),
+ this.customEntityDirtinessStrategy = strategySelector.resolveDefaultableStrategy(
CustomEntityDirtinessStrategy.class,
+ configurationSettings.get( AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY ),
DefaultCustomEntityDirtinessStrategy.INSTANCE
);
- this.currentTenantIdentifierResolver = strategyInstanceResolver.resolveStrategyInstance(
- configurationSettings.get( AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER ),
- CurrentTenantIdentifierResolver.class
+ this.currentTenantIdentifierResolver = strategySelector.resolveStrategy(
+ CurrentTenantIdentifierResolver.class,
+ configurationSettings.get( AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER )
);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationBindingContextImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationBindingContextImpl.java
index 1b160aa9cf..c5f64eca40 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationBindingContextImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationBindingContextImpl.java
@@ -42,7 +42,7 @@ import org.hibernate.metamodel.spi.domain.Type;
import org.hibernate.metamodel.spi.source.IdentifierGeneratorSource;
import org.hibernate.metamodel.spi.source.MappingDefaults;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelper.java
index 7c4d6d0bba..74f87f78ad 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelper.java
@@ -45,7 +45,7 @@ import org.jboss.jandex.Type;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* Utility methods for working with the jandex annotation index.
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java
index cf1416c115..1869ed3fa5 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java
@@ -43,7 +43,7 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.filter.IndexedAnnotationFilter;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Strong Liu
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/MockHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/MockHelper.java
index 4fc5e95e4b..5a21f8997c 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/MockHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/MockHelper.java
@@ -46,7 +46,7 @@ import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbCascadeType;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Strong Liu
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java
index 6b384f09da..085a443570 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java
@@ -39,6 +39,8 @@ import org.jboss.logging.Logger;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.LockMode;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.cfg.HbmBinder;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.ResultSetMappingDefinition;
@@ -94,8 +96,6 @@ import org.hibernate.metamodel.spi.relational.BasicAuxiliaryDatabaseObjectImpl;
import org.hibernate.metamodel.spi.source.FilterDefinitionSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.TypeDescriptorSource;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.type.Type;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/JavaType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/JavaType.java
index 9e9ac26b3f..b774becae7 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/JavaType.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/JavaType.java
@@ -24,7 +24,7 @@
package org.hibernate.metamodel.spi.domain;
import org.hibernate.internal.util.ValueHolder;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* Models the naming of a Java type where we may not have access to that type's {@link Class} reference. Generally
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/Type.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/Type.java
index 9a90b28e84..066e1117c1 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/Type.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/domain/Type.java
@@ -50,7 +50,7 @@ public interface Type {
*
* @return The {@link Class} reference
*
- * @throws org.hibernate.service.classloading.spi.ClassLoadingException Indicates the class reference
+ * @throws org.hibernate.boot.registry.classloading.spi.ClassLoadingException Indicates the class reference
* could not be determined. Generally this is the case in reverse-engineering scenarios where the specified
* domain model classes do not yet exist.
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
index 642836295a..cdefbfa91b 100644
--- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
+++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
@@ -364,7 +364,7 @@ public abstract class AbstractCollectionPersister
iter = collection.getElement().getColumnIterator();
while ( iter.hasNext() ) {
Selectable selectable = (Selectable) iter.next();
- elementColumnAliases[j] = selectable.getAlias( dialect );
+ elementColumnAliases[j] = selectable.getAlias( dialect, table );
if ( selectable.isFormula() ) {
Formula form = (Formula) selectable;
elementFormulaTemplates[j] = form.getTemplate( dialect, factory.getSqlFunctionRegistry() );
diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java
index 0f5a9d71b7..95db7a0271 100644
--- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java
@@ -25,16 +25,16 @@ package org.hibernate.persister.internal;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.persister.spi.PersisterClassResolver;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class PersisterClassResolverInitiator implements BasicServiceInitiator {
+public class PersisterClassResolverInitiator implements StandardServiceInitiator {
public static final PersisterClassResolverInitiator INSTANCE = new PersisterClassResolverInitiator();
public static final String IMPL_NAME = "hibernate.persister.resolver";
diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java
index 74227a9c60..2ad3ae3614 100644
--- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java
@@ -25,16 +25,16 @@ package org.hibernate.persister.internal;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.persister.spi.PersisterFactory;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class PersisterFactoryInitiator implements BasicServiceInitiator {
+public class PersisterFactoryInitiator implements StandardServiceInitiator {
public static final PersisterFactoryInitiator INSTANCE = new PersisterFactoryInitiator();
public static final String IMPL_NAME = "hibernate.persister.factory";
diff --git a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java
index 9b0a74e24a..623b54e35d 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistry.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -24,10 +24,8 @@
package org.hibernate.service;
/**
- * Specialization of the {@link ServiceRegistry} contract mainly to make the
- * {@link ServiceRegistryBuilder#ServiceRegistryBuilder(BootstrapServiceRegistry)} signature type-safe
- *
- * @author Steve Ebersole
+ * @deprecated Use {@link org.hibernate.boot.registry.BootstrapServiceRegistry} instead
*/
-public interface BootstrapServiceRegistry extends ServiceRegistry {
+@Deprecated
+public interface BootstrapServiceRegistry extends org.hibernate.boot.registry.BootstrapServiceRegistry {
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java
index 165c9b436a..5d707232dd 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/BootstrapServiceRegistryBuilder.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -23,105 +23,51 @@
*/
package org.hibernate.service;
-import java.util.LinkedHashSet;
-
-import org.hibernate.integrator.internal.IntegratorServiceImpl;
import org.hibernate.integrator.spi.Integrator;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
-import org.hibernate.service.internal.BootstrapServiceRegistryImpl;
/**
- * Builder for bootstrap {@link ServiceRegistry} instances.
- *
- * @author Steve Ebersole
- *
- * @see BootstrapServiceRegistryImpl
- * @see ServiceRegistryBuilder#ServiceRegistryBuilder(BootstrapServiceRegistry)
+ * @deprecated Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder} instead
*/
-public class BootstrapServiceRegistryBuilder {
- private final LinkedHashSet providedIntegrators = new LinkedHashSet();
- private ClassLoader applicationClassLoader;
- private ClassLoader resourcesClassLoader;
- private ClassLoader hibernateClassLoader;
- private ClassLoader environmentClassLoader;
-
- /**
- * Add an {@link Integrator} to be applied to the bootstrap registry.
- *
- * @param integrator The integrator to add.
- * @return {@code this}, for method chaining
- */
+@Deprecated
+public class BootstrapServiceRegistryBuilder extends org.hibernate.boot.registry.BootstrapServiceRegistryBuilder {
+ @Override
public BootstrapServiceRegistryBuilder with(Integrator integrator) {
- providedIntegrators.add( integrator );
+ super.with( integrator );
return this;
}
- /**
- * Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry
- *
- * @param classLoader The class loader to use
- * @return {@code this}, for method chaining
- */
- @SuppressWarnings( {"UnusedDeclaration"})
+ @Override
public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) {
- this.applicationClassLoader = classLoader;
+ super.withApplicationClassLoader( classLoader );
return this;
}
- /**
- * Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry
- *
- * @param classLoader The class loader to use
- * @return {@code this}, for method chaining
- */
- @SuppressWarnings( {"UnusedDeclaration"})
+ @Override
public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) {
- this.resourcesClassLoader = classLoader;
+ super.withResourceClassLoader( classLoader );
return this;
}
- /**
- * Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry
- *
- * @param classLoader The class loader to use
- * @return {@code this}, for method chaining
- */
- @SuppressWarnings( {"UnusedDeclaration"})
+ @Override
public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) {
- this.hibernateClassLoader = classLoader;
+ super.withHibernateClassLoader( classLoader );
return this;
}
- /**
- * Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry
- *
- * @param classLoader The class loader to use
- * @return {@code this}, for method chaining
- */
- @SuppressWarnings( {"UnusedDeclaration"})
+ @Override
public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) {
- this.environmentClassLoader = classLoader;
+ super.withEnvironmentClassLoader( classLoader );
return this;
}
- /**
- * Build the bootstrap registry.
- *
- * @return The built bootstrap registry
- */
+ @Override
+ public BootstrapServiceRegistryBuilder withStrategySelector(Class strategy, String name, Class extends T> implementation) {
+ super.withStrategySelector( strategy, name, implementation );
+ return this;
+ }
+
+ @Override
public BootstrapServiceRegistry build() {
- final ClassLoaderServiceImpl classLoaderService = new ClassLoaderServiceImpl(
- applicationClassLoader,
- resourcesClassLoader,
- hibernateClassLoader,
- environmentClassLoader
- );
-
- final IntegratorServiceImpl integratorService = new IntegratorServiceImpl(
- providedIntegrators,
- classLoaderService
- );
-
- return new BootstrapServiceRegistryImpl( classLoaderService, integratorService );
+ return (BootstrapServiceRegistry) super.build();
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java b/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java
index 4fb6fa731c..598625506d 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/ConfigLoader.java
@@ -29,13 +29,14 @@ import java.util.Properties;
import org.jboss.logging.Logger;
-import org.hibernate.internal.util.ValueHolder;
-import org.hibernate.internal.util.config.ConfigurationException;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.jaxb.internal.JaxbConfigurationProcessor;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.SourceType;
+import org.hibernate.internal.util.ValueHolder;
+import org.hibernate.internal.util.config.ConfigurationException;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
/**
* Loads {@code cfg.xml} files.
diff --git a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java
index 910f301a8f..87fba8c9af 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistry.java
@@ -37,8 +37,8 @@ public interface ServiceRegistry {
public ServiceRegistry getParentServiceRegistry();
/**
- * Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.BasicServiceInitiator} is registered for
- * this service role, the service will be initialized and returned.
+ * Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.ServiceInitiator} is
+ * registered for this service role, the service will be initialized and returned.
*
* NOTE: We cannot return {@code >} here because the service might come from the parent...
*
diff --git a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java
index 73157d1cc7..6d9c358aef 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -23,214 +23,67 @@
*/
package org.hibernate.service;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import org.hibernate.cfg.Environment;
-import org.hibernate.integrator.spi.Integrator;
-import org.hibernate.integrator.spi.IntegratorService;
-import org.hibernate.integrator.spi.ServiceContributingIntegrator;
-import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.internal.BootstrapServiceRegistryImpl;
-import org.hibernate.service.internal.ProvidedService;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.service.spi.BasicServiceInitiator;
-import org.hibernate.service.spi.ServiceContributor;
+import org.hibernate.boot.registry.StandardServiceInitiator;
/**
- * Builder for standard {@link ServiceRegistry} instances.
- *
- * @author Steve Ebersole
- *
- * @see StandardServiceRegistryImpl
- * @see BootstrapServiceRegistryBuilder
+ * @deprecated Use {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} instead
*/
-public class ServiceRegistryBuilder {
- public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml";
-
- private final Map settings;
- private final List initiators = standardInitiatorList();
- private final List providedServices = new ArrayList();
-
- private final BootstrapServiceRegistry bootstrapServiceRegistry;
- private final ConfigLoader configLoader;
-
- /**
- * Create a default builder
- */
+@Deprecated
+public class ServiceRegistryBuilder extends org.hibernate.boot.registry.StandardServiceRegistryBuilder {
public ServiceRegistryBuilder() {
- this( new BootstrapServiceRegistryImpl() );
+ super(); //To change body of overridden methods use File | Settings | File Templates.
}
- /**
- * Create a builder with the specified bootstrap services.
- *
- * @param bootstrapServiceRegistry Provided bootstrap registry to use.
- */
public ServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry) {
- this.settings = Environment.getProperties();
- this.bootstrapServiceRegistry = bootstrapServiceRegistry;
- this.configLoader = new ConfigLoader( bootstrapServiceRegistry );
+ super( bootstrapServiceRegistry ); //To change body of overridden methods use File | Settings | File Templates.
}
- /**
- * Allows access to the underlying boot-strap registry.
- *
- * @return The boot-strap registry
- */
- public BootstrapServiceRegistry getBootstrapServiceRegistry() {
- return bootstrapServiceRegistry;
- }
-
- /**
- * Used from the {@link #initiators} variable initializer
- *
- * @return List of standard initiators
- */
- private static List standardInitiatorList() {
- final List initiators = new ArrayList();
- initiators.addAll( StandardServiceInitiators.LIST );
- return initiators;
- }
-
- /**
- * Read settings from a {@link Properties} file. Differs from {@link #configure()} and {@link #configure(String)}
- * in that here we read a {@link Properties} file while for {@link #configure} we read the XML variant.
- *
- * @param resourceName The name by which to perform a resource look up for the properties file.
- *
- * @return this, for method chaining
- *
- * @see #configure()
- * @see #configure(String)
- */
- @SuppressWarnings( {"unchecked"})
+ @Override
public ServiceRegistryBuilder loadProperties(String resourceName) {
- settings.putAll( configLoader.loadProperties( resourceName ) );
+ super.loadProperties( resourceName );
return this;
}
- /**
- * Read setting information from an XML file using the standard resource location
- *
- * @return this, for method chaining
- *
- * @see #DEFAULT_CFG_RESOURCE_NAME
- * @see #configure(String)
- * @see #loadProperties(String)
- */
+ @Override
public ServiceRegistryBuilder configure() {
- return configure( DEFAULT_CFG_RESOURCE_NAME );
+ super.configure();
+ return this;
}
- /**
- * Read setting information from an XML file using the named resource location
- *
- * @param resourceName The named resource
- *
- * @return this, for method chaining
- *
- * @see #loadProperties(String)
- */
- @SuppressWarnings( {"unchecked"})
+ @Override
public ServiceRegistryBuilder configure(String resourceName) {
- JaxbHibernateConfiguration configurationElement = configLoader.loadConfigXmlResource( resourceName );
- for ( JaxbHibernateConfiguration.JaxbSessionFactory.JaxbProperty xmlProperty : configurationElement.getSessionFactory().getProperty() ) {
- settings.put( xmlProperty.getName(), xmlProperty.getValue() );
- }
-
+ super.configure( resourceName );
return this;
}
- /**
- * Apply a setting value
- *
- * @param settingName The name of the setting
- * @param value The value to use.
- *
- * @return this, for method chaining
- */
- @SuppressWarnings( {"unchecked", "UnusedDeclaration"})
+ @Override
public ServiceRegistryBuilder applySetting(String settingName, Object value) {
- settings.put( settingName, value );
+ super.applySetting( settingName, value );
return this;
}
- /**
- * Apply a groups of setting values
- *
- * @param settings The incoming settings to apply
- *
- * @return this, for method chaining
- */
- @SuppressWarnings( {"unchecked", "UnusedDeclaration"})
+ @Override
public ServiceRegistryBuilder applySettings(Map settings) {
- this.settings.putAll( settings );
+ super.applySettings( settings );
return this;
}
- /**
- * Adds a service initiator.
- *
- * @param initiator The initiator to be added
- *
- * @return this, for method chaining
- */
- @SuppressWarnings( {"UnusedDeclaration"})
- public ServiceRegistryBuilder addInitiator(BasicServiceInitiator initiator) {
- initiators.add( initiator );
+ @Override
+ public ServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
+ super.addInitiator( initiator );
return this;
}
- /**
- * Adds a user-provided service
- *
- * @param serviceRole The role of the service being added
- * @param service The service implementation
- *
- * @return this, for method chaining
- */
- @SuppressWarnings( {"unchecked"})
- public ServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
- providedServices.add( new ProvidedService( serviceRole, service ) );
+ @Override
+ public ServiceRegistryBuilder addService(Class serviceRole, Service service) {
+ super.addService( serviceRole, service );
return this;
}
- /**
- * Build the service registry accounting for all settings and service initiators and services.
- *
- * @return The built service registry
- */
+ @Override
public ServiceRegistry buildServiceRegistry() {
- Map,?> settingsCopy = new HashMap();
- settingsCopy.putAll( settings );
- Environment.verifyProperties( settingsCopy );
- ConfigurationHelper.resolvePlaceHolders( settingsCopy );
-
- for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ).getIntegrators() ) {
- if ( ServiceContributingIntegrator.class.isInstance( integrator ) ) {
- ServiceContributingIntegrator.class.cast( integrator ).prepareServices( this );
- }
- }
-
- for ( ServiceContributor contributor : bootstrapServiceRegistry.getService( ClassLoaderService.class ).loadJavaServices(ServiceContributor.class) ) {
- contributor.contribute( this );
- }
-
- return new StandardServiceRegistryImpl( bootstrapServiceRegistry, initiators, providedServices, settingsCopy );
- }
-
- /**
- * Destroy a service registry. Applications should only destroy registries they have explicitly created.
- *
- * @param serviceRegistry The registry to be closed.
- */
- public static void destroy(ServiceRegistry serviceRegistry) {
- ( (StandardServiceRegistryImpl) serviceRegistry ).destroy();
+ return super.buildServiceRegistry();
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java
index ad5e3bf4c1..1c945077b2 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java
@@ -27,25 +27,25 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator;
import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator;
import org.hibernate.engine.transaction.internal.TransactionFactoryInitiator;
import org.hibernate.id.factory.internal.MutableIdentifierGeneratorFactoryInitiator;
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
import org.hibernate.persister.internal.PersisterFactoryInitiator;
-import org.hibernate.service.config.internal.ConfigurationServiceInitiator;
+import org.hibernate.engine.config.internal.ConfigurationServiceInitiator;
import org.hibernate.service.internal.SessionFactoryServiceRegistryFactoryInitiator;
-import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
-import org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator;
-import org.hibernate.service.jdbc.cursor.internal.RefCursorSupportInitiator;
-import org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator;
-import org.hibernate.service.jdbc.dialect.internal.DialectResolverInitiator;
+import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
+import org.hibernate.engine.jdbc.connections.internal.MultiTenantConnectionProviderInitiator;
+import org.hibernate.engine.jdbc.cursor.internal.RefCursorSupportInitiator;
+import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryInitiator;
+import org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator;
+import org.hibernate.jmx.internal.JmxServiceInitiator;
+import org.hibernate.engine.jndi.internal.JndiServiceInitiator;
+import org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator;
import org.hibernate.service.jdbc.env.internal.JdbcEnvironmentInitiator;
-import org.hibernate.service.jmx.internal.JmxServiceInitiator;
-import org.hibernate.service.jndi.internal.JndiServiceInitiator;
-import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
import org.hibernate.service.schema.internal.SchemaManagementToolInitiator;
-import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractorInitiator;
/**
@@ -54,10 +54,10 @@ import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractorInitiator;
* @author Steve Ebersole
*/
public class StandardServiceInitiators {
- public static List LIST = buildStandardServiceInitiatorList();
+ public static List LIST = buildStandardServiceInitiatorList();
- private static List buildStandardServiceInitiatorList() {
- final List serviceInitiators = new ArrayList();
+ private static List buildStandardServiceInitiatorList() {
+ final List serviceInitiators = new ArrayList();
serviceInitiators.add( ConfigurationServiceInitiator.INSTANCE );
serviceInitiators.add( ImportSqlCommandExtractorInitiator.INSTANCE );
diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/StrategyInstanceResolverImpl.java b/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/StrategyInstanceResolverImpl.java
deleted file mode 100644
index 3afdbf7183..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/service/classloading/internal/StrategyInstanceResolverImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.service.classloading.internal;
-
-import org.hibernate.HibernateException;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
-
-/**
- * A helper to deal with the common idiom of loading a named strategy implementer.
- *
- * @author Steve Ebersole
- */
-public class StrategyInstanceResolverImpl implements StrategyInstanceResolver {
-
- // todo : maybe even allow passing in a "construction handler" to deal with non-no-arg cases
-
- private final ClassLoaderService classLoaderService;
-
- public StrategyInstanceResolverImpl(ClassLoaderService classLoaderService) {
- this.classLoaderService = classLoaderService;
- }
-
- @Override
- public T resolveStrategyInstance(Object strategyReference, Class type) {
- return resolveDefaultableStrategyInstance( strategyReference, type, null );
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T resolveDefaultableStrategyInstance(Object strategyReference, Class type, T defaultValue) {
- if ( strategyReference == null ) {
- return defaultValue;
- }
-
- if ( type.isInstance( strategyReference ) ) {
- return type.cast( strategyReference );
- }
-
- final Class implementationClass;
- if ( Class.class.isInstance( strategyReference ) ) {
- implementationClass = (Class) strategyReference;
- }
- else {
- implementationClass = (Class) classLoaderService.classForName( strategyReference.toString() );
- }
-
- try {
- return implementationClass.newInstance();
- }
- catch (Exception e) {
- throw new HibernateException(
- String.format( "Could not instantiate named strategy class [%s]", implementationClass.getName() ),
- e
- );
- }
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/StrategyInstanceResolver.java b/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/StrategyInstanceResolver.java
deleted file mode 100644
index 7c43796094..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/service/classloading/spi/StrategyInstanceResolver.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.service.classloading.spi;
-
-/**
- * A helper to deal with the common idiom of loading a named strategy implementer.
- *
- * @author Steve Ebersole
- */
-public interface StrategyInstanceResolver {
- /**
- * Resolve strategy instances. See discussion on {@link #resolveDefaultableStrategyInstance}.
- * Only difference is that here, the implied default value is {@code null}.
- *
- * @param strategyReference The reference to the strategy for which we need to resolve an instance.
- * @param type The type (interface) of the strategy to be resolved.
- * @param The parameterized java type type.
- *
- * @return The strategy instance
- */
- public T resolveStrategyInstance(Object strategyReference, Class type);
-
- /**
- * Resolve strategy instances. The incoming reference might be:
- *
- * {@code null} - in which case defaultValue is returned.
- *
- *
- * An actual instance of the strategy type - it is returned, as is
- *
- *
- * A reference to the implementation {@link Class} - an instance is created by calling
- * {@link Class#newInstance()} (aka, the class's no-arg ctor).
- *
- *
- * The name of the implementation class - First the implementation's {@link Class} reference
- * is resolved, and then an instance is created by calling {@link Class#newInstance()}
- *
- *
- *
- * @param strategyReference The reference to the strategy for which we need to resolve an instance.
- * @param type The type (interface) of the strategy to be resolved.
- * @param defaultValue THe default value to use if strategyReference is null
- * @param The parameterized java type type.
- *
- * @return The strategy instance
- */
- public T resolveDefaultableStrategyInstance(Object strategyReference, Class type, T defaultValue);
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/config/spi/StandardConverters.java b/hibernate-core/src/main/java/org/hibernate/service/config/spi/StandardConverters.java
index d3dbea939a..664ca86366 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/config/spi/StandardConverters.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/config/spi/StandardConverters.java
@@ -23,7 +23,8 @@
*/
package org.hibernate.service.config.spi;
-import static org.hibernate.service.config.spi.ConfigurationService.Converter;
+
+import static org.hibernate.engine.config.spi.ConfigurationService.Converter;
/**
* Standard set of setting converters
@@ -31,7 +32,7 @@ import static org.hibernate.service.config.spi.ConfigurationService.Converter;
* @author Steve Ebersole
*/
public class StandardConverters {
- public static final Converter BOOLEAN = new Converter() {
+ public static final Converter BOOLEAN = new Converter() {
@Override
public Boolean convert(Object value) {
if ( value == null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java
index dda22639b0..0b160a1636 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java
@@ -32,11 +32,11 @@ import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
-import org.hibernate.service.BootstrapServiceRegistry;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.UnknownServiceException;
-import org.hibernate.service.jmx.spi.JmxService;
+import org.hibernate.jmx.spi.JmxService;
import org.hibernate.service.spi.InjectService;
import org.hibernate.service.spi.Manageable;
import org.hibernate.service.spi.ServiceBinding;
diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java
index 3e0236f443..8d1c00ebfa 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java
@@ -31,7 +31,7 @@ import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
/**
- * Acts as a {@link Service} in the {@link StandardServiceRegistryImpl} whose function is as a factory for
+ * Acts as a {@link Service} in the {@link org.hibernate.boot.registry.internal.StandardServiceRegistryImpl} whose function is as a factory for
* {@link SessionFactoryServiceRegistryImpl} implementations.
*
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java
index 5cabc73b87..e935561682 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java
@@ -25,14 +25,14 @@ package org.hibernate.service.internal;
import java.util.Map;
-import org.hibernate.service.spi.BasicServiceInitiator;
+import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
/**
* @author Steve Ebersole
*/
-public class SessionFactoryServiceRegistryFactoryInitiator implements BasicServiceInitiator {
+public class SessionFactoryServiceRegistryFactoryInitiator implements StandardServiceInitiator {
public static final SessionFactoryServiceRegistryFactoryInitiator INSTANCE = new SessionFactoryServiceRegistryFactoryInitiator();
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/JdbcConnectionAccess.java b/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/JdbcConnectionAccess.java
index 7ea1c3fb85..1fa6f1f49a 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/JdbcConnectionAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/jdbc/connections/spi/JdbcConnectionAccess.java
@@ -56,8 +56,8 @@ public interface JdbcConnectionAccess extends Serializable {
* Does the underlying provider of connections support aggressive releasing of connections (and re-acquisition
* of those connections later, if need be) in JTA environments?
*
- * @see org.hibernate.service.jdbc.connections.spi.ConnectionProvider#supportsAggressiveRelease()
- * @see org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider#supportsAggressiveRelease()
+ * @see org.hibernate.engine.jdbc.connections.spi.ConnectionProvider#supportsAggressiveRelease()
+ * @see org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider#supportsAggressiveRelease()
*/
public boolean supportsAggressiveRelease();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentImpl.java b/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentImpl.java
index 70eb25153c..8a1f721741 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentImpl.java
@@ -31,8 +31,11 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.config.spi.ConfigurationService;
+import org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport;
import org.hibernate.engine.jdbc.internal.TypeInfo;
import org.hibernate.engine.jdbc.internal.TypeInfoExtracter;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
@@ -41,10 +44,7 @@ import org.hibernate.exception.internal.SQLStateConversionDelegate;
import org.hibernate.exception.internal.StandardSQLExceptionConverter;
import org.hibernate.exception.spi.SQLExceptionConverter;
import org.hibernate.metamodel.spi.relational.Identifier;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
-import org.hibernate.service.jdbc.cursor.internal.StandardRefCursorSupport;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.IdentifierHelper;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
@@ -232,9 +232,11 @@ public class JdbcEnvironmentImpl implements JdbcEnvironment {
final Object setting = serviceRegistry.getService( ConfigurationService.class )
.getSettings()
.get( AvailableSettings.SCHEMA_NAME_RESOLVER );
- return serviceRegistry.getService( ClassLoaderService.class )
- .getStrategyInstanceResolver()
- .resolveDefaultableStrategyInstance( setting, SchemaNameResolver.class, TemporarySchemaNameResolver.INSTANCE );
+ return serviceRegistry.getService( StrategySelector.class ).resolveDefaultableStrategy(
+ SchemaNameResolver.class,
+ setting,
+ TemporarySchemaNameResolver.INSTANCE
+ );
}
private Set buildMergedReservedWords(Dialect dialect, DatabaseMetaData dbmd) throws SQLException {
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentInitiator.java b/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentInitiator.java
index dc9277d4b6..b21854e686 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/jdbc/env/internal/JdbcEnvironmentInitiator.java
@@ -31,20 +31,20 @@ import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.MultiTenancyStrategy;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
+import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
-import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
-import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
-import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class JdbcEnvironmentInitiator implements BasicServiceInitiator {
+public class JdbcEnvironmentInitiator implements StandardServiceInitiator {
private static final CoreMessageLogger log = Logger.getMessageLogger(
CoreMessageLogger.class,
JdbcEnvironmentInitiator.class.getName()
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaPlatformInitiator.java b/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaPlatformInitiator.java
deleted file mode 100644
index 5c7fb6d5cc..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/JtaPlatformInitiator.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.service.jta.platform.internal;
-
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.Environment;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.util.jndi.JndiHelper;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
-import org.hibernate.service.jta.platform.spi.JtaPlatformException;
-import org.hibernate.service.spi.BasicServiceInitiator;
-import org.hibernate.service.spi.ServiceRegistryImplementor;
-import org.hibernate.transaction.TransactionManagerLookup;
-
-/**
- * Standard initiator for the standard {@link org.hibernate.service.jta.platform.spi.JtaPlatform}
- *
- * @author Steve Ebersole
- */
-public class JtaPlatformInitiator implements BasicServiceInitiator {
- public static final JtaPlatformInitiator INSTANCE = new JtaPlatformInitiator();
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, JtaPlatformInitiator.class.getName());
-
- @Override
- public Class getServiceInitiated() {
- return JtaPlatform.class;
- }
-
- @Override
- @SuppressWarnings( {"unchecked"})
- public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
- final Object platform = getConfiguredPlatform( configurationValues, registry );
- if ( platform == null ) {
- return new NoJtaPlatform();
- }
- return registry.getService( ConfigurationService.class )
- .cast( JtaPlatform.class, platform );
-
- }
-
- private Object getConfiguredPlatform(Map configVales, ServiceRegistryImplementor registry) {
- Object platform = configVales.get( AvailableSettings.JTA_PLATFORM );
- if ( platform == null ) {
- final String transactionManagerLookupImplName = (String) configVales.get( Environment.TRANSACTION_MANAGER_STRATEGY );
- if ( transactionManagerLookupImplName != null ) {
- LOG.deprecatedTransactionManagerStrategy(TransactionManagerLookup.class.getName(),
- Environment.TRANSACTION_MANAGER_STRATEGY,
- JtaPlatform.class.getName(),
- AvailableSettings.JTA_PLATFORM);
- platform = mapLegacyClasses( transactionManagerLookupImplName, configVales, registry );
- LOG.debugf("Mapped %s -> %s", transactionManagerLookupImplName, platform);
- }
- }
- return platform;
- }
-
- private JtaPlatform mapLegacyClasses(String tmlImplName, Map configVales, ServiceRegistryImplementor registry) {
- if ( tmlImplName == null ) {
- return null;
- }
-
- LOG.legacyTransactionManagerStrategy(JtaPlatform.class.getName(), AvailableSettings.JTA_PLATFORM);
-
- if ( "org.hibernate.transaction.BESTransactionManagerLookup".equals( tmlImplName ) ) {
- return new BorlandEnterpriseServerJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.BTMTransactionManagerLookup".equals( tmlImplName ) ) {
- return new BitronixJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.JBossTransactionManagerLookup".equals( tmlImplName ) ) {
- return new JBossAppServerJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup".equals( tmlImplName ) ) {
- return new JBossStandAloneJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.JOnASTransactionManagerLookup".equals( tmlImplName ) ) {
- return new JOnASJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.JOTMTransactionManagerLookup".equals( tmlImplName ) ) {
- return new JOTMJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.JRun4TransactionManagerLookup".equals( tmlImplName ) ) {
- return new JRun4JtaPlatform();
- }
-
- if ( "org.hibernate.transaction.OC4JTransactionManagerLookup".equals( tmlImplName ) ) {
- return new OC4JJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.OrionTransactionManagerLookup".equals( tmlImplName ) ) {
- return new OrionJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.ResinTransactionManagerLookup".equals( tmlImplName ) ) {
- return new ResinJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.SunONETransactionManagerLookup".equals( tmlImplName ) ) {
- return new SunOneJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.WeblogicTransactionManagerLookup".equals( tmlImplName ) ) {
- return new WeblogicJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.WebSphereTransactionManagerLookup".equals( tmlImplName ) ) {
- return new WebSphereJtaPlatform();
- }
-
- if ( "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup".equals( tmlImplName ) ) {
- return new WebSphereExtendedJtaPlatform();
- }
-
- try {
- TransactionManagerLookup lookup = (TransactionManagerLookup) registry.getService( ClassLoaderService.class )
- .classForName( tmlImplName )
- .newInstance();
- return new TransactionManagerLookupBridge( lookup, JndiHelper.extractJndiProperties( configVales ) );
- }
- catch ( Exception e ) {
- throw new JtaPlatformException(
- "Unable to build " + TransactionManagerLookupBridge.class.getName() + " from specified " +
- TransactionManagerLookup.class.getName() + " implementation: " +
- tmlImplName
- );
- }
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerLookupBridge.java b/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerLookupBridge.java
deleted file mode 100644
index bd3889ce99..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/service/jta/platform/internal/TransactionManagerLookupBridge.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.service.jta.platform.internal;
-
-import java.util.Properties;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
-import org.hibernate.service.jndi.spi.JndiService;
-import org.hibernate.transaction.TransactionManagerLookup;
-
-/**
- * @author Steve Ebersole
- */
-public class TransactionManagerLookupBridge extends AbstractJtaPlatform {
- private final TransactionManagerLookup lookup;
- private final Properties jndiProperties;
-
- public TransactionManagerLookupBridge(TransactionManagerLookup lookup, Properties jndiProperties) {
- this.lookup = lookup;
- this.jndiProperties = jndiProperties;
- }
-
- @Override
- protected TransactionManager locateTransactionManager() {
- return lookup.getTransactionManager( jndiProperties );
- }
-
- @Override
- protected UserTransaction locateUserTransaction() {
- return (UserTransaction) serviceRegistry().getService( JndiService.class ).locate( lookup.getUserTransactionName() );
- }
-
- @Override
- public Object getTransactionIdentifier(Transaction transaction) {
- return lookup.getTransactionIdentifier( transaction );
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/service/schema/internal/SchemaManagementToolInitiator.java b/hibernate-core/src/main/java/org/hibernate/service/schema/internal/SchemaManagementToolInitiator.java
index 26a0ac5586..45cbbb0abb 100644
--- a/hibernate-core/src/main/java/org/hibernate/service/schema/internal/SchemaManagementToolInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/service/schema/internal/SchemaManagementToolInitiator.java
@@ -25,23 +25,21 @@ package org.hibernate.service.schema.internal;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.schema.spi.SchemaManagementTool;
-import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
* @author Steve Ebersole
*/
-public class SchemaManagementToolInitiator implements BasicServiceInitiator {
+public class SchemaManagementToolInitiator implements StandardServiceInitiator {
public static final SchemaManagementToolInitiator INSTANCE = new SchemaManagementToolInitiator();
public SchemaManagementTool initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object setting = configurationValues.get( AvailableSettings.SCHEMA_MANAGEMENT_TOOL );
- SchemaManagementTool tool = registry.getService( ClassLoaderService.class )
- .getStrategyInstanceResolver()
- .resolveStrategyInstance( setting, SchemaManagementTool.class );
+ SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting );
if ( tool == null ) {
tool = new HibernateSchemaManagementTool();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java
index 52baa87f13..38c6391dc3 100644
--- a/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java
+++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/StatisticsInitiator.java
@@ -30,9 +30,9 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.CoreMessageLogger;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.SessionFactoryServiceInitiator;
@@ -107,8 +107,10 @@ public class StatisticsInitiator implements SessionFactoryServiceInitiator {
+public class ImportSqlCommandExtractorInitiator implements StandardServiceInitiator {
public static final ImportSqlCommandExtractorInitiator INSTANCE = new ImportSqlCommandExtractorInitiator();
public static final ImportSqlCommandExtractor DEFAULT_EXTRACTOR = new SingleLineSqlCommandExtractor();
diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java
index 00391b6b16..411866f517 100644
--- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java
@@ -28,12 +28,12 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
/**
* A {@link ConnectionHelper} implementation based on an internally
@@ -62,7 +62,7 @@ class ManagedProviderConnectionHelper implements ConnectionHelper {
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
- return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
+ return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
}
public Connection getConnection() throws SQLException {
diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
index d824cac3fb..2bc448ad5b 100644
--- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
+++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
@@ -43,6 +43,7 @@ import java.util.Properties;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
@@ -60,10 +61,9 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.config.spi.ConfigurationService;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.schema.spi.SchemaManagementTool;
/**
@@ -553,8 +553,7 @@ public class SchemaExport {
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
- return ( StandardServiceRegistryImpl ) new ServiceRegistryBuilder().applySettings( properties )
- .buildServiceRegistry();
+ return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
}
public static void main(String[] args) {
diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
index 713370850d..451fae85bf 100644
--- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
+++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
@@ -37,6 +37,7 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.JDBCException;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.NamingStrategy;
@@ -50,8 +51,7 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
/**
* A commandline tool to update a database schema. May also be called from inside an application.
@@ -110,7 +110,7 @@ public class SchemaUpdate {
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
- return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
+ return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
}
public static void main(String[] args) {
diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java
index af64cfa563..8a748cffdc 100755
--- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java
+++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java
@@ -31,6 +31,7 @@ import java.util.Properties;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.NamingStrategy;
@@ -40,8 +41,7 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
/**
* A commandline tool to update a database schema. May also be called from
@@ -79,7 +79,7 @@ public class SchemaValidator {
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
- return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
+ return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
}
public static void main(String[] args) {
diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java
index 8dd589ae43..b98f550629 100644
--- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java
@@ -28,7 +28,7 @@ import java.sql.Connection;
import java.sql.SQLException;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
/**
* A {@link ConnectionHelper} implementation based on a provided
diff --git a/hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java b/hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java
deleted file mode 100644
index 2656ae938f..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- *
- */
-package org.hibernate.transaction;
-import java.util.Properties;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.hibernate.HibernateException;
-
-/**
- * Contract for locating the JTA {@link TransactionManager} on given platform.
- *
- * NOTE: this contract has expanded over time, and basically is a platform
- * abstraction contract for JTA-related information.
- *
- * @author Gavin King
- */
-public interface TransactionManagerLookup {
-
- /**
- * Obtain the JTA {@link TransactionManager}.
- *
- * @param props The configuration properties.
- * @return The JTA {@link TransactionManager}.
- *
- * @throws HibernateException Indicates problem locating {@link TransactionManager}.
- */
- public TransactionManager getTransactionManager(Properties props) throws HibernateException;
-
- /**
- * Return the JNDI namespace of the JTA
- * {@link javax.transaction.UserTransaction} for this platform or null ;
- * optional operation.
- *
- * @return The JNDI namespace where we can locate the
- * {@link javax.transaction.UserTransaction} for this platform.
- */
- public String getUserTransactionName();
-
- /**
- * Determine an identifier for the given transaction appropriate for use in caching/lookup usages.
- *
- * Generally speaking the transaction itself will be returned here. This method was added specifically
- * for use in WebSphere and other unfriendly JEE containers (although WebSphere is still the only known
- * such brain-dead, sales-driven impl).
- *
- * @param transaction The transaction to be identified.
- * @return An appropropriate identifier
- */
- public Object getTransactionIdentifier(Transaction transaction);
-}
-
diff --git a/hibernate-core/src/main/java/org/hibernate/transaction/package.html b/hibernate-core/src/main/java/org/hibernate/transaction/package.html
deleted file mode 100755
index 895501cfc1..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/transaction/package.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
- This package abstracts the underlying transaction mechanism
- (JTA or JDBC) and provides strategies for obtaining application
- server TransactionManager s.
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java
index bf5e984fa9..0cf1a17d5f 100644
--- a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java
+++ b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * Copyright (c) 2008, 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
+ * distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@@ -23,6 +23,8 @@
*/
package org.hibernate.type;
+import javax.persistence.Enumerated;
+import javax.persistence.MapKeyEnumerated;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.sql.PreparedStatement;
@@ -30,165 +32,155 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Properties;
-import javax.persistence.Enumerated;
-import javax.persistence.MapKeyEnumerated;
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
-import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
+import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.usertype.DynamicParameterizedType;
import org.hibernate.usertype.EnhancedUserType;
/**
- * Enum type mapper
- * Try and find the appropriate SQL type depending on column metadata
- *
- * TODO implements readobject/writeobject to recalculate the enumclasses
+ * Value type mapper for enumerations.
+ *
+ * Generally speaking, the proper configuration is picked up from the annotations associated with the mapped attribute.
+ *
+ * There are a few configuration parameters understood by this type mapper:
+ *
+ * enumClass - Names the enumeration class.
+ *
+ *
+ * useNamed - Should enum be mapped via name. Default is to map as ordinal. Used when
+ * annotations are not used (otherwise {@link javax.persistence.EnumType} is used).
+ *
+ *
+ * type - Identifies the JDBC type (via type code) to be used for the column.
+ *
+ *
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
+ * @author Steve Ebersole
*/
@SuppressWarnings("unchecked")
public class EnumType implements EnhancedUserType, DynamicParameterizedType, Serializable {
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, EnumType.class.getName());
+ private static final Logger LOG = Logger.getLogger( EnumType.class.getName() );
public static final String ENUM = "enumClass";
- public static final String SCHEMA = "schema";
- public static final String CATALOG = "catalog";
- public static final String TABLE = "table";
- public static final String COLUMN = "column";
+ public static final String NAMED = "useNamed";
public static final String TYPE = "type";
private Class extends Enum> enumClass;
- private transient Object[] enumValues;
- private int sqlType = Types.INTEGER; //before any guessing
+ private EnumValueMapper enumValueMapper;
+ private int sqlType = Types.INTEGER; // before any guessing
+ @Override
public int[] sqlTypes() {
return new int[] { sqlType };
}
+ @Override
public Class extends Enum> returnedClass() {
return enumClass;
}
+ @Override
public boolean equals(Object x, Object y) throws HibernateException {
return x == y;
}
+ @Override
public int hashCode(Object x) throws HibernateException {
return x == null ? 0 : x.hashCode();
}
-
- public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
- Object object = rs.getObject( names[0] );
- if ( rs.wasNull() ) {
- if ( LOG.isTraceEnabled() ) LOG.tracev( "Returning null as column {0}", names[0] );
- return null;
+ @Override
+ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
+ if ( enumValueMapper == null ) {
+ guessTypeOfEnumValueMapper( rs.getMetaData().getColumnType( rs.findColumn( names[0] ) ) );
}
- if ( object instanceof Number ) {
- initEnumValues();
- int ordinal = ( ( Number ) object ).intValue();
- if (ordinal < 0 || ordinal >= enumValues.length) throw new IllegalArgumentException("Unknown ordinal value for enum "
- + enumClass + ": " + ordinal);
- if ( LOG.isTraceEnabled() ) LOG.tracev( "Returning '{0}' as column {1}", ordinal, names[0] );
- return enumValues[ordinal];
+ return enumValueMapper.getValue( rs, names );
+ }
+
+ private void guessTypeOfEnumValueMapper(int columnType) {
+ // fallback for cases where not enough parameter/parameterization information was passed in
+ if ( isOrdinal( columnType ) ) {
+ treatAsOrdinal();
}
else {
- String name = ( String ) object;
- if ( LOG.isTraceEnabled() ) LOG.tracev( "Returning '{0}' as column {1}", name, names[0] );
- try {
- return Enum.valueOf( enumClass, name );
- }
- catch ( IllegalArgumentException iae ) {
- throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + name, iae );
- }
+ treatAsNamed();
}
}
+ @Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
- if ( value == null ) {
- if ( LOG.isTraceEnabled() ) LOG.tracev( "Binding null to parameter: {0}", index );
- st.setNull( index, sqlType );
- }
- else {
- boolean isOrdinal = isOrdinal( sqlType );
- if ( isOrdinal ) {
- int ordinal = ( ( Enum> ) value ).ordinal();
- if ( LOG.isTraceEnabled() ) LOG.tracev( "Binding '{0}' to parameter: '{1}", ordinal, index );
- st.setObject( index, Integer.valueOf( ordinal ), sqlType );
- }
- else {
- String enumString = ( ( Enum> ) value ).name();
- if ( LOG.isTraceEnabled() ) LOG.tracev( "Binding '{0}' to parameter: {1}", enumString, index );
- st.setObject( index, enumString, sqlType );
- }
- }
- }
-
- private boolean isOrdinal(int paramType) {
- switch ( paramType ) {
- case Types.INTEGER:
- case Types.NUMERIC:
- case Types.SMALLINT:
- case Types.TINYINT:
- case Types.BIGINT:
- case Types.DECIMAL: //for Oracle Driver
- case Types.DOUBLE: //for Oracle Driver
- case Types.FLOAT: //for Oracle Driver
- return true;
- case Types.CHAR:
- case Types.LONGVARCHAR:
- case Types.VARCHAR:
- return false;
- default:
- throw new HibernateException( "Unable to persist an Enum in a column of SQL Type: " + paramType );
+ if ( enumValueMapper == null ) {
+ guessTypeOfEnumValueMapper( st.getParameterMetaData().getParameterType( index ) );
}
+ enumValueMapper.setValue( st, (Enum) value, index );
}
+ @Override
public Object deepCopy(Object value) throws HibernateException {
return value;
}
+ @Override
public boolean isMutable() {
return false;
}
+ @Override
public Serializable disassemble(Object value) throws HibernateException {
return ( Serializable ) value;
}
+ @Override
public Object assemble(Serializable cached, Object owner) throws HibernateException {
return cached;
}
+ @Override
public Object replace(Object original, Object target, Object owner) throws HibernateException {
return original;
}
+ @Override
public void setParameterValues(Properties parameters) {
- ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
+ final ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
+
+ // IMPL NOTE : be protective about not setting enumValueMapper (i.e. calling treatAsNamed/treatAsOrdinal)
+ // in cases where we do not have enough information. In such cases the `if` check in nullSafeGet/nullSafeSet
+ // will kick in to query against the JDBC metadata to make that determination.
if ( reader != null ) {
enumClass = reader.getReturnedClass().asSubclass( Enum.class );
- javax.persistence.EnumType enumType = getEnumType( reader );
- if ( enumType != null ) {
- if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) {
- sqlType = Types.INTEGER;
- }
- else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) {
- sqlType = Types.VARCHAR;
- }
- else {
- throw new AssertionFailure( "Unknown EnumType: " + enumType );
- }
+ final boolean isOrdinal;
+ final javax.persistence.EnumType enumType = getEnumType( reader );
+ if ( enumType == null ) {
+ isOrdinal = true;
}
+ else if ( javax.persistence.EnumType.ORDINAL.equals( enumType ) ) {
+ isOrdinal = true;
+ }
+ else if ( javax.persistence.EnumType.STRING.equals( enumType ) ) {
+ isOrdinal = false;
+ }
+ else {
+ throw new AssertionFailure( "Unknown EnumType: " + enumType );
+ }
+
+ if ( isOrdinal ) {
+ treatAsOrdinal();
+ }
+ else {
+ treatAsNamed();
+ }
+ sqlType = enumValueMapper.getSqlType();
}
else {
String enumClassName = (String) parameters.get( ENUM );
@@ -199,63 +191,34 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType, Ser
throw new HibernateException( "Enum class not found", exception );
}
- String type = (String) parameters.get( TYPE );
- if ( type != null ) {
- sqlType = Integer.decode( type );
+ final Object useNamedSetting = parameters.get( NAMED );
+ if ( useNamedSetting != null ) {
+ final boolean useNamed = ConfigurationHelper.getBoolean( NAMED, parameters );
+ if ( useNamed ) {
+ treatAsNamed();
+ }
+ else {
+ treatAsOrdinal();
+ }
+ sqlType = enumValueMapper.getSqlType();
}
}
+
+ final String type = (String) parameters.get( TYPE );
+ if ( type != null ) {
+ sqlType = Integer.decode( type );
+ }
}
- /**
- * Lazy init of {@link #enumValues}.
- */
- private void initEnumValues() {
- if ( enumValues == null ) {
- this.enumValues = enumClass.getEnumConstants();
- if ( enumValues == null ) {
- throw new NullPointerException( "Failed to init enumValues" );
- }
+ private void treatAsOrdinal() {
+ if ( enumValueMapper == null || ! OrdinalEnumValueMapper.class.isInstance( enumValueMapper ) ) {
+ enumValueMapper = new OrdinalEnumValueMapper();
}
}
- public String objectToSQLString(Object value) {
- boolean isOrdinal = isOrdinal( sqlType );
- if ( isOrdinal ) {
- int ordinal = ( ( Enum ) value ).ordinal();
- return Integer.toString( ordinal );
- }
- else {
- return '\'' + ( ( Enum ) value ).name() + '\'';
- }
- }
-
- public String toXMLString(Object value) {
- boolean isOrdinal = isOrdinal( sqlType );
- if ( isOrdinal ) {
- int ordinal = ( ( Enum ) value ).ordinal();
- return Integer.toString( ordinal );
- }
- else {
- return ( ( Enum ) value ).name();
- }
- }
-
- public Object fromXMLString(String xmlValue) {
- try {
- int ordinal = Integer.parseInt( xmlValue );
- initEnumValues();
- if ( ordinal < 0 || ordinal >= enumValues.length ) {
- throw new IllegalArgumentException( "Unknown ordinal value for enum " + enumClass + ": " + ordinal );
- }
- return enumValues[ordinal];
- }
- catch ( NumberFormatException e ) {
- try {
- return Enum.valueOf( enumClass, xmlValue );
- }
- catch ( IllegalArgumentException iae ) {
- throw new IllegalArgumentException( "Unknown name value for enum " + enumClass + ": " + xmlValue, iae );
- }
+ private void treatAsNamed() {
+ if ( enumValueMapper == null || ! NamedEnumValueMapper.class.isInstance( enumValueMapper ) ) {
+ enumValueMapper = new NamedEnumValueMapper();
}
}
@@ -284,4 +247,202 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType, Ser
}
return null;
}
+
+ @Override
+ public String objectToSQLString(Object value) {
+ return enumValueMapper.objectToSQLString( (Enum) value );
+ }
+
+ @Override
+ public String toXMLString(Object value) {
+ return enumValueMapper.toXMLString( (Enum) value );
+ }
+
+ @Override
+ public Object fromXMLString(String xmlValue) {
+ return enumValueMapper.fromXMLString( xmlValue );
+ }
+
+ private static interface EnumValueMapper {
+ public int getSqlType();
+ public Enum getValue(ResultSet rs, String[] names) throws SQLException;
+ public void setValue(PreparedStatement st, Enum value, int index) throws SQLException;
+
+ public String objectToSQLString(Enum value);
+ public String toXMLString(Enum value);
+ public Enum fromXMLString(String xml);
+ }
+
+ public abstract class EnumValueMapperSupport implements EnumValueMapper {
+ protected abstract Object extractJdbcValue(Enum value);
+
+ @Override
+ public void setValue(PreparedStatement st, Enum value, int index) throws SQLException {
+ final Object jdbcValue = value == null ? null : extractJdbcValue( value );
+
+ if ( jdbcValue == null ) {
+ if ( LOG.isTraceEnabled() ) {
+ LOG.tracev( "Binding null to parameter: {0}", index );
+ }
+ st.setNull( index, getSqlType() );
+ return;
+ }
+
+ if ( LOG.isTraceEnabled() ) {
+ LOG.tracev( "Binding '{0}' to parameter: '{1}", jdbcValue, index );
+ }
+ st.setObject( index, jdbcValue, EnumType.this.sqlType );
+ }
+ }
+
+ private class OrdinalEnumValueMapper extends EnumValueMapperSupport implements EnumValueMapper {
+ private transient Enum[] enumsByOrdinal;
+
+ @Override
+ public int getSqlType() {
+ return Types.INTEGER;
+ }
+
+ @Override
+ public Enum getValue(ResultSet rs, String[] names) throws SQLException {
+ final int ordinal = rs.getInt( names[0] );
+ if ( rs.wasNull() ) {
+ if ( LOG.isTraceEnabled() ) {
+ LOG.tracev( "Returning null as column {0}", names[0] );
+ }
+ return null;
+ }
+
+ final Enum enumValue = fromOrdinal( ordinal );
+ if ( LOG.isTraceEnabled() ) {
+ LOG.tracev( "Returning '{0}' as column {1}", enumValue, names[0] );
+ }
+ return enumValue;
+ }
+
+ private Enum fromOrdinal(int ordinal) {
+ final Enum[] enumsByOrdinal = enumsByOrdinal();
+ if ( ordinal < 0 || ordinal >= enumsByOrdinal.length ) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Unknown ordinal value [%s] for enum class [%s]",
+ ordinal,
+ enumClass.getName()
+ )
+ );
+ }
+ return enumsByOrdinal[ordinal];
+
+ }
+
+ private Enum[] enumsByOrdinal() {
+ if ( enumsByOrdinal == null ) {
+ enumsByOrdinal = enumClass.getEnumConstants();
+ if ( enumsByOrdinal == null ) {
+ throw new HibernateException( "Failed to init enum values" );
+ }
+ }
+ return enumsByOrdinal;
+ }
+
+ @Override
+ public String objectToSQLString(Enum value) {
+ return toXMLString( value );
+ }
+
+ @Override
+ public String toXMLString(Enum value) {
+ return Integer.toString( value.ordinal() );
+ }
+
+ @Override
+ public Enum fromXMLString(String xml) {
+ return fromOrdinal( Integer.parseInt( xml ) );
+ }
+
+ @Override
+ protected Object extractJdbcValue(Enum value) {
+ return value.ordinal();
+ }
+ }
+
+ private class NamedEnumValueMapper extends EnumValueMapperSupport implements EnumValueMapper {
+ @Override
+ public int getSqlType() {
+ return Types.VARCHAR;
+ }
+
+ @Override
+ public Enum getValue(ResultSet rs, String[] names) throws SQLException {
+ final String value = rs.getString( names[0] );
+
+ if ( rs.wasNull() ) {
+ if ( LOG.isTraceEnabled() ) {
+ LOG.tracev( "Returning null as column {0}", names[0] );
+ }
+ return null;
+ }
+
+ final Enum enumValue = fromName( value );
+ if ( LOG.isTraceEnabled() ) {
+ LOG.tracev( "Returning '{0}' as column {1}", enumValue, names[0] );
+ }
+ return enumValue;
+ }
+
+ private Enum fromName(String name) {
+ try {
+ return Enum.valueOf( enumClass, name );
+ }
+ catch ( IllegalArgumentException iae ) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Unknown name value [%s] for enum class [%s]",
+ name,
+ enumClass.getName()
+ )
+ );
+ }
+ }
+
+ @Override
+ public String objectToSQLString(Enum value) {
+ return '\'' + toXMLString( value ) + '\'';
+ }
+
+ @Override
+ public String toXMLString(Enum value) {
+ return value.name();
+ }
+
+ @Override
+ public Enum fromXMLString(String xml) {
+ return fromName( xml );
+ }
+
+ @Override
+ protected Object extractJdbcValue(Enum value) {
+ return value.name();
+ }
+ }
+
+ private boolean isOrdinal(int paramType) {
+ switch ( paramType ) {
+ case Types.INTEGER:
+ case Types.NUMERIC:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ case Types.BIGINT:
+ case Types.DECIMAL: //for Oracle Driver
+ case Types.DOUBLE: //for Oracle Driver
+ case Types.FLOAT: //for Oracle Driver
+ return true;
+ case Types.CHAR:
+ case Types.LONGVARCHAR:
+ case Types.VARCHAR:
+ return false;
+ default:
+ throw new HibernateException( "Unable to persist an Enum in a column of SQL Type: " + paramType );
+ }
+ }
}
diff --git a/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java b/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java
index d11ea335a0..e7eb70ebe7 100644
--- a/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java
+++ b/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java
@@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Properties;
import org.dom4j.Node;
-
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
@@ -43,14 +42,14 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.SerializationHelper;
-import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.usertype.DynamicParameterizedType;
/**
* @author Emmanuel Bernard
*/
-public class SerializableToBlobType extends AbstractLobType implements ParameterizedType {
+public class SerializableToBlobType extends AbstractLobType implements DynamicParameterizedType {
/**
- * class name of the serialisable class
+ * class name of the serialisable class
*/
public static final String CLASS_NAME = "classname";
private Class serializableClass;
@@ -138,17 +137,19 @@ public class SerializableToBlobType extends AbstractLobType implements Parameter
}
public void setParameterValues(Properties parameters) {
- if ( parameters != null ) {
+ ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
+ if ( reader != null ) {
+ serializableClass = reader.getReturnedClass();
+ }
+ else {
String className = parameters.getProperty( CLASS_NAME );
if ( className == null ) {
- throw new MappingException(
- "No class name defined for type: " + SerializableToBlobType.class.getName()
- );
+ throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
}
try {
serializableClass = ReflectHelper.classForName( className );
}
- catch (ClassNotFoundException e) {
+ catch ( ClassNotFoundException e ) {
throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java b/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java
index 6b072c3611..07043eda19 100644
--- a/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java
+++ b/hibernate-core/src/main/java/org/hibernate/usertype/DynamicParameterizedType.java
@@ -1,10 +1,31 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.usertype;
import java.lang.annotation.Annotation;
/**
- * {@inheritDoc}
- *
* Types who implements this interface will have in the setParameterValues an
* instance of the class DynamicParameterizedType$ParameterType instead of
* the key PARAMETER_TYPE = "org.hibernate.type.ParameterType"
diff --git a/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java b/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java
index f3dda7a149..ff1eed36b7 100644
--- a/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/cfg/beanvalidation/ApplySchemaConstraintTest.java
@@ -36,6 +36,10 @@ import javax.validation.constraints.NotNull;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
@@ -45,11 +49,7 @@ import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.metamodel.spi.relational.Value;
-import org.hibernate.service.BootstrapServiceRegistry;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.validator.constraints.Length;
import static junit.framework.Assert.assertEquals;
@@ -160,7 +160,7 @@ public class ApplySchemaConstraintTest {
private StandardServiceRegistryImpl createServiceRegistry() {
final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
final BootstrapServiceRegistry bootstrapServiceRegistry = builder.build();
- ServiceRegistryBuilder registryBuilder = new ServiceRegistryBuilder( bootstrapServiceRegistry );
+ StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry );
return ( StandardServiceRegistryImpl ) registryBuilder.buildServiceRegistry();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java b/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java
index c1a0e70f7f..1ae674536b 100644
--- a/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/connection/PropertiesTest.java
@@ -27,7 +27,7 @@ import java.util.Properties;
import org.junit.Assert;
import org.junit.Test;
-import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
+import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java b/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java
index dd440c5deb..8c7bb01edf 100644
--- a/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java
+++ b/hibernate-core/src/test/java/org/hibernate/dialect/TestingDialects.java
@@ -26,8 +26,8 @@ import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import org.hibernate.HibernateException;
-import org.hibernate.service.jdbc.dialect.internal.AbstractDialectResolver;
-import org.hibernate.service.jdbc.dialect.internal.BasicDialectResolver;
+import org.hibernate.engine.jdbc.dialect.internal.AbstractDialectResolver;
+import org.hibernate.engine.jdbc.dialect.internal.BasicDialectResolver;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java
index 4d763ff5a5..f166212290 100644
--- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java
@@ -29,10 +29,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
-
import org.hibernate.HibernateException;
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder;
+import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.DB2400Dialect;
import org.hibernate.dialect.DB2Dialect;
@@ -55,12 +56,14 @@ import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseAnywhereDialect;
import org.hibernate.dialect.TestingDialects;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
-import org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl;
-import org.hibernate.service.jdbc.dialect.internal.DialectResolverSet;
-import org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver;
-import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
+import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl;
+import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet;
+import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver;
+import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
+
+import org.junit.Before;
+import org.junit.Test;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
@@ -76,10 +79,23 @@ public class DialectFactoryTest extends BaseUnitTestCase {
@Before
public void setUp() {
dialectFactory = new DialectFactoryImpl();
- dialectFactory.setClassLoaderService( new ClassLoaderServiceImpl( getClass().getClassLoader() ) );
+ dialectFactory.setStrategySelector(
+ new StrategySelectorBuilder().buildSelector( new ClassLoaderServiceImpl( getClass().getClassLoader() ) )
+ );
dialectFactory.setDialectResolver( new StandardDialectResolver() );
}
+ @Test
+ public void testExplicitShortNameUse() {
+ final Map configValues = new HashMap();
+
+ configValues.put( Environment.DIALECT, "H2" );
+ assertEquals( H2Dialect.class, dialectFactory.buildDialect( configValues, null ).getClass() );
+
+ configValues.put( Environment.DIALECT, "Oracle10g" );
+ assertEquals( Oracle10gDialect.class, dialectFactory.buildDialect( configValues, null ).getClass() );
+ }
+
@Test
public void testExplicitlySuppliedDialectClassName() {
final Map configValues = new HashMap();
@@ -93,7 +109,7 @@ public class DialectFactoryTest extends BaseUnitTestCase {
fail();
}
catch ( HibernateException e ) {
- assertEquals( "unexpected exception type", ClassLoadingException.class, e.getCause().getClass() );
+ assertEquals( "unexpected exception type", StrategySelectionException.class, e.getClass() );
}
configValues.put( Environment.DIALECT, "java.lang.Object" );
diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java
index ae774dcb61..ba49a7e109 100644
--- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectResolverTest.java
@@ -30,9 +30,9 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Mocks;
import org.hibernate.dialect.TestingDialects;
import org.hibernate.exception.JDBCConnectionException;
-import org.hibernate.service.jdbc.dialect.internal.BasicDialectResolver;
-import org.hibernate.service.jdbc.dialect.internal.DialectResolverSet;
-import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
+import org.hibernate.engine.jdbc.dialect.internal.BasicDialectResolver;
+import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet;
+import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
diff --git a/hibernate-core/src/test/java/org/hibernate/jmx/Entity.java b/hibernate-core/src/test/java/org/hibernate/jmx/Entity.java
deleted file mode 100644
index 035a2dddb7..0000000000
--- a/hibernate-core/src/test/java/org/hibernate/jmx/Entity.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.hibernate.jmx;
-
-
-/**
- * {@inheritDoc}
- *
- * @author Steve Ebersole
- */
-public class Entity {
- private Long id;
- private String name;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/MetadataImplTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/MetadataImplTest.java
index ceb0620573..2d92c01057 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/MetadataImplTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/MetadataImplTest.java
@@ -29,13 +29,14 @@ import org.junit.Test;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.metamodel.Metadata;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.SessionFactoryBuilder;
+import org.hibernate.metamodel.spi.binding.FetchProfile;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.internal.SessionFactoryBuilderImpl;
-import org.hibernate.metamodel.spi.binding.FetchProfile;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static junit.framework.Assert.assertEquals;
@@ -50,29 +51,29 @@ public class MetadataImplTest extends BaseUnitTestCase {
@Test(expected = IllegalArgumentException.class)
public void testAddingNullClass() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addClass( null );
sources.buildMetadata();
}
@Test(expected = IllegalArgumentException.class)
public void testAddingNullPackageName() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addPackage( null );
sources.buildMetadata();
}
@Test(expected = HibernateException.class)
public void testAddingNonExistingPackageName() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addPackage( "not.a.package" );
sources.buildMetadata();
}
@Test
public void testAddingPackageName() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
- sources.addPackage( MetadataImplTest.class.getPackage().getName() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
+ sources.addPackage( "org.hibernate.metamodel.source.internal" );
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
assertFetchProfile( metadata );
@@ -80,8 +81,8 @@ public class MetadataImplTest extends BaseUnitTestCase {
@Test
public void testAddingPackageNameWithTrailingDot() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
- sources.addPackage( MetadataImplTest.class.getPackage().getName() + "." );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
+ sources.addPackage( "org.hibernate.metamodel.source.internal." );
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
assertFetchProfile( metadata );
@@ -89,7 +90,7 @@ public class MetadataImplTest extends BaseUnitTestCase {
@Test
public void testGettingSessionFactoryBuilder() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
Metadata metadata = sources.buildMetadata();
SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/SessionFactoryBuilderImplTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/SessionFactoryBuilderImplTest.java
index cb5230ec7c..6676fbcde8 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/SessionFactoryBuilderImplTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/SessionFactoryBuilderImplTest.java
@@ -35,12 +35,13 @@ import org.hibernate.Interceptor;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.SessionFactoryBuilder;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.internal.SessionFactoryBuilderImpl;
import org.hibernate.proxy.EntityNotFoundDelegate;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.type.Type;
@@ -90,7 +91,7 @@ public class SessionFactoryBuilderImplTest extends BaseUnitTestCase {
}
private SessionFactoryBuilder getSessionFactoryBuilder() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addAnnotatedClass( SimpleEntity.class );
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
return metadata.getSessionFactoryBuilder();
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java
index 180d9b4f8c..24241bb453 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java
@@ -24,14 +24,20 @@
package org.hibernate.metamodel.internal.source.annotations.entity;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import org.junit.Test;
-
import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.id.Assigned;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.IdentityGenerator;
@@ -42,19 +48,16 @@ import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
import org.hibernate.metamodel.spi.source.MappingException;
-import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
+import org.junit.Test;
/**
* @author Hardy Ferentschik
*/
+@RequiresDialect(H2Dialect.class)
public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase {
@Entity
class NoGenerationEntity {
@@ -149,7 +152,7 @@ public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase {
@Test
public void testUndefinedGenerator() {
try {
- sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addAnnotatedClass( NamedGeneratorEntity.class );
sources.buildMetadata();
fail();
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/MapsIdTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/MapsIdTest.java
index 53ee398a38..2dcd2fe572 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/MapsIdTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/MapsIdTest.java
@@ -33,11 +33,11 @@ import javax.persistence.OneToMany;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.source.MappingException;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
-import org.hibernate.testing.junit4.Resources;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
@@ -72,10 +72,9 @@ public class MapsIdTest extends BaseAnnotationBindingTestCase {
}
@Test
- @Resources(annotatedClasses = { })
public void testMapsIsOnOneToManyThrowsException() {
try {
- sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addAnnotatedClass( DependentId.class );
sources.addAnnotatedClass( Dependent.class );
sources.addAnnotatedClass( Employee.class );
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java
index a6c98a618e..614a88f973 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java
@@ -34,13 +34,14 @@ import org.hibernate.MappingException;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.FetchProfile;
import org.hibernate.annotations.FetchProfiles;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContextImpl;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static junit.framework.Assert.fail;
@@ -58,7 +59,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase {
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
service = serviceRegistry.getService( ClassLoaderService.class );
meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/QueryBinderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/QueryBinderTest.java
index da888279e1..a92dacfb91 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/QueryBinderTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/QueryBinderTest.java
@@ -30,17 +30,18 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryRootReturn;
import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.metamodel.MetadataSources;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContextImpl;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static junit.framework.Assert.assertEquals;
@@ -51,14 +52,13 @@ import static junit.framework.Assert.assertTrue;
* @author Hardy Ferentschik
*/
public class QueryBinderTest extends BaseUnitTestCase {
-
private StandardServiceRegistryImpl serviceRegistry;
private ClassLoaderService service;
private MetadataImpl meta;
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
service = serviceRegistry.getService( ClassLoaderService.class );
meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/BaseAnnotationIndexTestCase.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/BaseAnnotationIndexTestCase.java
index 48b019dc9a..07b7477124 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/BaseAnnotationIndexTestCase.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/BaseAnnotationIndexTestCase.java
@@ -31,14 +31,15 @@ import org.junit.After;
import org.junit.Before;
import org.hibernate.metamodel.MetadataSources;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContextImpl;
import org.hibernate.metamodel.internal.source.annotations.entity.EmbeddableHierarchy;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.source.EntityHierarchy;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
/**
@@ -49,7 +50,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
@Before
public void setUp() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
meta = (MetadataImpl) sources.buildMetadata();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java
index e78fac1ef8..af5d368f70 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java
@@ -43,9 +43,9 @@ import org.junit.Test;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.NamedNativeQuery;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static junit.framework.Assert.assertTrue;
@@ -64,7 +64,7 @@ public class JandexHelperTest extends BaseUnitTestCase {
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/OrmXmlParserTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/OrmXmlParserTests.java
index 414b2dea13..30398338aa 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/OrmXmlParserTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/OrmXmlParserTests.java
@@ -25,11 +25,11 @@ package org.hibernate.metamodel.internal.source.annotations.xml;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.source.MappingException;
-import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static junit.framework.Assert.assertNotNull;
@@ -40,7 +40,7 @@ import static junit.framework.Assert.assertNotNull;
public class OrmXmlParserTests extends BaseUnitTestCase {
@Test
public void testSimpleOrmVersion2() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addResource( "org/hibernate/metamodel/internal/source/annotations/xml/orm-father.xml" );
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
@@ -50,7 +50,7 @@ public class OrmXmlParserTests extends BaseUnitTestCase {
@Test
public void testSimpleOrmVersion1() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addResource( "org/hibernate/metamodel/internal/source/annotations/xml/orm-star.xml" );
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
@@ -60,7 +60,7 @@ public class OrmXmlParserTests extends BaseUnitTestCase {
@Test(expected = MappingException.class)
public void testInvalidOrmXmlThrowsException() {
- MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ MetadataSources sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
sources.addResource( "org/hibernate/metamodel/internal/source/annotations/xml/orm-invalid.xml" );
sources.buildMetadata();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/AbstractMockerTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/AbstractMockerTest.java
index 176e78b72b..162eafb5a1 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/AbstractMockerTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/AbstractMockerTest.java
@@ -40,7 +40,7 @@ import org.hibernate.AnnotationException;
import org.hibernate.HibernateException;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.testing.ServiceRegistryBuilder;
import static org.junit.Assert.assertEquals;
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/XmlHelper.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/XmlHelper.java
index 9b4daeec39..b94211570f 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/XmlHelper.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/XmlHelper.java
@@ -39,7 +39,7 @@ import org.xml.sax.SAXException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.jaxb.spi.Origin;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Hardy Ferentschik
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractBasicBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractBasicBindingTests.java
index c89e424b64..ff88113f19 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractBasicBindingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractBasicBindingTests.java
@@ -32,6 +32,8 @@ import org.junit.Before;
import org.junit.Test;
import org.hibernate.FetchMode;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.CascadeStyles;
import org.hibernate.metamodel.MetadataSources;
@@ -46,8 +48,6 @@ import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.metamodel.spi.relational.JdbcDataType;
import org.hibernate.metamodel.spi.relational.Value;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.type.LongType;
import org.hibernate.type.StringType;
@@ -70,7 +70,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
}
@After
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractUnsavedValueTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractUnsavedValueTests.java
index 382c4a6636..a7d5beb68c 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractUnsavedValueTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/AbstractUnsavedValueTests.java
@@ -36,11 +36,11 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
@@ -51,12 +51,11 @@ import static org.junit.Assert.assertEquals;
* @author Gail Badner
*/
public abstract class AbstractUnsavedValueTests extends BaseUnitTestCase {
-
private StandardServiceRegistryImpl serviceRegistry;
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
}
@After
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/JoinedSubclassBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/JoinedSubclassBindingTests.java
index 76adac9dd6..2ef89f1897 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/JoinedSubclassBindingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/JoinedSubclassBindingTests.java
@@ -32,10 +32,10 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertTrue;
@@ -48,7 +48,7 @@ public class JoinedSubclassBindingTests extends BaseUnitTestCase {
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
}
@After
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/SimpleValueBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/SimpleValueBindingTests.java
index becc4ffd0c..3999b9ad93 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/SimpleValueBindingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/SimpleValueBindingTests.java
@@ -31,6 +31,7 @@ import java.util.List;
import org.junit.Test;
import org.hibernate.EntityMode;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.spi.domain.Entity;
@@ -41,7 +42,6 @@ import org.hibernate.metamodel.spi.relational.JdbcDataType;
import org.hibernate.metamodel.spi.relational.Schema;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.metamodel.spi.relational.Table;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertSame;
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java
index bc0bf55727..fd0769de21 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java
@@ -27,13 +27,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.metamodel.MetadataSourceProcessingOrder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.Identifier;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@@ -48,7 +48,7 @@ public class UnidirectionalManyToManyBindingTests extends BaseUnitTestCase {
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
}
@After
@@ -77,9 +77,12 @@ public class UnidirectionalManyToManyBindingTests extends BaseUnitTestCase {
final EntityBinding simpleEntityBinding = metadata.getEntityBinding( SimpleEntity.class.getName() );
assertNotNull( entityBinding );
- assertEquals( Identifier.toIdentifier( "SimpleEntity" ), simpleEntityBinding.getPrimaryTable().getLogicalName() );
+ assertEquals(
+ Identifier.toIdentifier( "SimpleEntity" ),
+ simpleEntityBinding.getPrimaryTable().getLogicalName()
+ );
assertEquals( 1, simpleEntityBinding.getPrimaryTable().getPrimaryKey().getColumnSpan() );
Column simpleEntityIdColumn = simpleEntityBinding.getPrimaryTable().getPrimaryKey().getColumns().get( 0 );
- assertEquals( Identifier.toIdentifier("id") , simpleEntityIdColumn.getColumnName() );
+ assertEquals( Identifier.toIdentifier( "id" ) , simpleEntityIdColumn.getColumnName() );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/AbstractBasicCollectionBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/AbstractBasicCollectionBindingTests.java
index bd688265df..26978139d6 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/AbstractBasicCollectionBindingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/AbstractBasicCollectionBindingTests.java
@@ -31,6 +31,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
@@ -47,8 +49,6 @@ import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.metamodel.spi.relational.TableSpecification;
import org.hibernate.metamodel.spi.relational.Value;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.type.BagType;
import org.hibernate.type.CollectionType;
@@ -70,7 +70,7 @@ public abstract class AbstractBasicCollectionBindingTests extends BaseUnitTestCa
@Before
public void setUp() {
- serviceRegistry = ( StandardServiceRegistryImpl ) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = ( StandardServiceRegistryImpl ) new StandardServiceRegistryBuilder().buildServiceRegistry();
MetadataSources metadataSources = new MetadataSources( serviceRegistry );
addSources( metadataSources );
metadata = ( MetadataImpl ) metadataSources.getMetadataBuilder().buildMetadata();
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/AbstractUnidirectionalOneToManyBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/AbstractUnidirectionalOneToManyBindingTests.java
index 1e67575841..45951ae335 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/AbstractUnidirectionalOneToManyBindingTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/AbstractUnidirectionalOneToManyBindingTests.java
@@ -33,6 +33,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
@@ -46,8 +48,6 @@ import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.metamodel.spi.relational.Value;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.type.BagType;
import org.hibernate.type.CollectionType;
@@ -71,7 +71,7 @@ public abstract class AbstractUnidirectionalOneToManyBindingTests extends BaseUn
@Before
public void setUp() {
- serviceRegistry = ( StandardServiceRegistryImpl ) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = ( StandardServiceRegistryImpl ) new StandardServiceRegistryBuilder().buildServiceRegistry();
MetadataSources metadataSources = new MetadataSources( serviceRegistry );
addSources( metadataSources );
metadata = ( MetadataImpl ) metadataSources.getMetadataBuilder().buildMetadata();
diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/relational/AbstractGeneratedIdColumnTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/relational/AbstractGeneratedIdColumnTests.java
index 048f207e1c..b95b79f348 100644
--- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/relational/AbstractGeneratedIdColumnTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/relational/AbstractGeneratedIdColumnTests.java
@@ -32,13 +32,13 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
@@ -49,12 +49,11 @@ import static org.junit.Assert.assertEquals;
* @author Gail Badner
*/
public abstract class AbstractGeneratedIdColumnTests extends BaseUnitTestCase {
-
private StandardServiceRegistryImpl serviceRegistry;
@Before
public void setUp() {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().buildServiceRegistry();
}
@After
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java
index c33c929cff..9b74e4de73 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/ordered/Person.java
@@ -30,6 +30,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.OrderBy;
import org.hibernate.annotations.GenericGenerator;
@@ -73,6 +74,7 @@ public class Person {
@ElementCollection
@JoinColumn
+ @JoinTable(name = "T_NICKNAMES_A")
@OrderBy
public Set getNickNamesAscendingNaturalSort() {
return nickNamesAscendingNaturalSort;
@@ -84,6 +86,7 @@ public class Person {
@ElementCollection
@JoinColumn
+ @JoinTable(name = "T_NICKNAMES_D")
@OrderBy( "desc" )
public Set getNickNamesDescendingNaturalSort() {
return nickNamesDescendingNaturalSort;
@@ -97,6 +100,7 @@ public class Person {
@ElementCollection
@JoinColumn
@OrderBy
+ @JoinTable(name = "T_ADDRESS_A")
public Set getAddressesAscendingNaturalSort() {
return addressesAscendingNaturalSort;
}
@@ -108,6 +112,7 @@ public class Person {
@ElementCollection
@JoinColumn
@OrderBy( "desc" )
+ @JoinTable(name = "T_ADDRESS_D")
public Set getAddressesDescendingNaturalSort() {
return addressesDescendingNaturalSort;
}
@@ -119,6 +124,7 @@ public class Person {
@ElementCollection
@JoinColumn
@OrderBy( "city" )
+ @JoinTable(name = "T_ADD_CITY_A")
public Set getAddressesCityAscendingSort() {
return addressesCityAscendingSort;
}
@@ -130,6 +136,7 @@ public class Person {
@ElementCollection
@JoinColumn
@OrderBy( "city desc" )
+ @JoinTable(name = "T_ADD_CITY_D")
public Set getAddressesCityDescendingSort() {
return addressesCityDescendingSort;
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java
new file mode 100644
index 0000000000..52b2266560
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CompositeKeyDeleteTest.java
@@ -0,0 +1,121 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.lazy;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.Item;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+import org.junit.Test;
+
+public class CompositeKeyDeleteTest extends BaseCoreFunctionalTestCase {
+
+ public String[] getMappings() {
+ return new String[] { "annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml" };
+ }
+
+ public CompositeKeyDeleteTest() {
+ System.setProperty( "hibernate.enable_specj_proprietary_syntax", "true" );
+ }
+ /**
+ * This test checks to make sure the non null column is not updated with a
+ * null value when a CustomerInventory is removed.
+ */
+ @Test
+ public void testRemove() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+
+ CustomerTwo c1 = new CustomerTwo(
+ "foo", "bar", "contact1", "100", new BigDecimal( 1000 ), new BigDecimal( 1000 ), new BigDecimal( 1000 )
+ );
+
+ s.persist( c1 );
+ s.flush();
+ s.clear();
+
+ Item boat = new Item();
+ boat.setId( "1" );
+ boat.setName( "cruiser" );
+ boat.setPrice( new BigDecimal( 500 ) );
+ boat.setDescription( "a boat" );
+ boat.setCategory( 42 );
+
+ s.persist( boat );
+
+
+ Item house = new Item();
+ house.setId( "2" );
+ house.setName( "blada" );
+ house.setPrice( new BigDecimal( 5000 ) );
+ house.setDescription( "a house" );
+ house.setCategory( 74 );
+
+ s.persist( house );
+ s.flush();
+ s.clear();
+
+ c1.addInventory( boat, 10, new BigDecimal( 5000 ) );
+
+ c1.addInventory( house, 100, new BigDecimal( 50000 ) );
+ s.merge( c1 );
+ Integer id = c1.getId();
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+
+ CustomerTwo c12 = ( CustomerTwo) s.createQuery( "select c from CustomerTwo c" ).uniqueResult();
+ Assert.assertNotNull(c12);
+ List list = c12.getInventories();
+ Assert.assertNotNull(list);
+ Assert.assertEquals(2, list.size());
+ CustomerInventoryTwo ci = list.get(1);
+ list.remove(ci);
+ s.delete(ci);
+ s.flush();
+
+ tx.commit();//fail
+ s.close();
+
+ }
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[] {
+ CustomerTwo.class,
+ CustomerInventoryTwo.class,
+ CustomerInventoryTwoPK.class,
+ Item.class
+
+ };
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java
new file mode 100644
index 0000000000..ea34c711be
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwo.java
@@ -0,0 +1,147 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.lazy;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Comparator;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Version;
+
+import org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.Item;
+
+@NamedQueries({ @NamedQuery(name = "CustomerInventoryTwo.selectAll", query = "select a from CustomerInventoryTwo a") })
+@SuppressWarnings("serial")
+@Entity
+@Table(name = "O_CUSTINVENTORY")
+@IdClass(CustomerInventoryTwoPK.class)
+public class CustomerInventoryTwo implements Serializable,
+ Comparator {
+
+ @Id
+ @TableGenerator(name = "inventory", table = "U_SEQUENCES", pkColumnName = "S_ID", valueColumnName = "S_NEXTNUM", pkColumnValue = "inventory", allocationSize = 1000)
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "inventory")
+ @Column(name = "CI_ID")
+ private Integer id;
+
+ @Id
+ @Column(name = "CI_CUSTOMERID", insertable = false, updatable = false)
+ private int custId;
+
+ @ManyToOne(cascade = CascadeType.MERGE)
+ @JoinColumn(name = "CI_CUSTOMERID", nullable = false)
+ private CustomerTwo customer;
+
+ @ManyToOne(cascade = CascadeType.MERGE)
+ @JoinColumn(name = "CI_ITEMID")
+ private Item vehicle;
+
+ @Column(name = "CI_VALUE")
+ private BigDecimal totalCost;
+
+ @Column(name = "CI_QUANTITY")
+ private int quantity;
+
+ @Version
+ @Column(name = "CI_VERSION")
+ private int version;
+
+ protected CustomerInventoryTwo() {
+ }
+
+ CustomerInventoryTwo(CustomerTwo customer, Item vehicle, int quantity,
+ BigDecimal totalValue) {
+ this.customer = customer;
+ this.vehicle = vehicle;
+ this.quantity = quantity;
+ this.totalCost = totalValue;
+ }
+
+ public Item getVehicle() {
+ return vehicle;
+ }
+
+ public BigDecimal getTotalCost() {
+ return totalCost;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public CustomerTwo getCustomer() {
+ return customer;
+ }
+
+ public int getCustId() {
+ return custId;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public int compare(CustomerInventoryTwo cdb1, CustomerInventoryTwo cdb2) {
+ return cdb1.id.compareTo(cdb2.id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj == null || !(obj instanceof CustomerInventoryTwo)) {
+ return false;
+ }
+ if (this.id == ((CustomerInventoryTwo) obj).id) {
+ return true;
+ }
+ if (this.id != null && ((CustomerInventoryTwo) obj).id == null) {
+ return false;
+ }
+ if (this.id == null && ((CustomerInventoryTwo) obj).id != null) {
+ return false;
+ }
+
+ return this.id.equals(((CustomerInventoryTwo) obj).id);
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java
new file mode 100644
index 0000000000..236290a979
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerInventoryTwoPK.java
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.lazy;
+
+import java.io.Serializable;
+
+public class CustomerInventoryTwoPK implements Serializable {
+
+ private Integer id;
+ private int custId;
+
+ public CustomerInventoryTwoPK() {
+ }
+
+ public CustomerInventoryTwoPK(Integer id, int custId) {
+ this.id = id;
+ this.custId = custId;
+ }
+
+ public boolean equals(Object other) {
+ if ( other == this ) {
+ return true;
+ }
+ if ( other == null || getClass() != other.getClass() ) {
+ return false;
+ }
+ CustomerInventoryTwoPK cip = ( CustomerInventoryTwoPK ) other;
+ return ( custId == cip.custId && ( id == cip.id ||
+ ( id != null && id.equals( cip.id ) ) ) );
+ }
+
+ public int hashCode() {
+ return ( id == null ? 0 : id.hashCode() ) ^ custId;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public int getCustId() {
+ return custId;
+ }
+
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java
new file mode 100644
index 0000000000..d548959eea
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/CustomerTwo.java
@@ -0,0 +1,248 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.lazy;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Version;
+
+import org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.Item;
+
+@SuppressWarnings("serial")
+@NamedQueries({
+ @NamedQuery(name = CustomerTwo.QUERY_ALL,
+ query = "select a from CustomerTwo a"),
+ @NamedQuery(name = CustomerTwo.QUERY_COUNT,
+ query = "select COUNT(a) from CustomerTwo a"),
+ @NamedQuery(name = CustomerTwo.QUERY_BY_CREDIT,
+ query = "SELECT c.id FROM CustomerTwo c WHERE c.creditLimit > :limit")
+})
+@Entity
+@Table(name = "O_CUSTOMER")
+public class CustomerTwo implements Serializable{
+ public static final String QUERY_ALL = "CustomerTwo.selectAll";
+ public static final String QUERY_COUNT = "CustomerTwo.count";
+ public static final String QUERY_BY_CREDIT = "CustomerTwo.selectByCreditLimit";
+
+ public static final String BAD_CREDIT = "BC";
+
+ @Id
+ @Column(name = "C_ID")
+ private int id;
+
+ @Column(name = "C_FIRST")
+ private String firstName;
+
+ @Column(name = "C_LAST")
+ private String lastName;
+
+ @Column(name = "C_CONTACT")
+ private String contact;
+
+ @Column(name = "C_CREDIT")
+ private String credit;
+
+ @Column(name = "C_CREDIT_LIMIT")
+ private BigDecimal creditLimit;
+
+ @Column(name = "C_SINCE")
+ @Temporal(TemporalType.DATE)
+ private Calendar since;
+
+ @Column(name = "C_BALANCE")
+ private BigDecimal balance;
+
+ @Column(name = "C_YTD_PAYMENT")
+ private BigDecimal ytdPayment;
+
+ @OneToMany(targetEntity = CustomerInventoryTwo.class,
+ mappedBy = "customer",
+ cascade = CascadeType.ALL,
+ fetch = FetchType.EAGER)
+ private List customerInventories;
+
+
+ @Version
+ @Column(name = "C_VERSION")
+ private int version;
+
+ protected CustomerTwo() {
+ }
+
+ public CustomerTwo(String first, String last,
+ String contact, String credit, BigDecimal creditLimit,
+ BigDecimal balance, BigDecimal YtdPayment) {
+
+ this.firstName = first;
+ this.lastName = last;
+ this.contact = contact;
+ this.since = Calendar.getInstance();
+ this.credit = credit;
+ this.creditLimit = creditLimit;
+ this.balance = balance;
+ this.ytdPayment = YtdPayment;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer customerId) {
+ this.id = customerId;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getContact() {
+ return contact;
+ }
+
+ public void setContact(String contact) {
+ this.contact = contact;
+ }
+
+ public String getCredit() {
+ return credit;
+ }
+
+ public void setCredit(String credit) {
+ this.credit = credit;
+ }
+
+ public BigDecimal getCreditLimit() {
+ return creditLimit;
+ }
+
+ public void setCreditLimit(BigDecimal creditLimit) {
+ this.creditLimit = creditLimit;
+ }
+
+ public Calendar getSince() {
+ return since;
+ }
+
+ public void setSince(Calendar since) {
+ this.since = since;
+ }
+
+ public BigDecimal getBalance() {
+ return balance;
+ }
+
+ public void setBalance(BigDecimal balance) {
+ this.balance = balance;
+ }
+
+ public void changeBalance(BigDecimal change) {
+ setBalance( balance.add( change ).setScale( 2, BigDecimal.ROUND_DOWN ) );
+ }
+
+ public BigDecimal getYtdPayment() {
+ return ytdPayment;
+ }
+
+ public void setYtdPayment(BigDecimal ytdPayment) {
+ this.ytdPayment = ytdPayment;
+ }
+
+
+ public List getInventories() {
+ if ( this.customerInventories == null ) {
+ this.customerInventories = new ArrayList();
+ }
+ return this.customerInventories;
+ }
+
+ public CustomerInventoryTwo addInventory(Item item, int quantity,
+ BigDecimal totalValue) {
+
+ CustomerInventoryTwo inventory = new CustomerInventoryTwo(
+ this, item,
+ quantity, totalValue
+ );
+ getInventories().add( inventory );
+ return inventory;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public boolean hasSufficientCredit(BigDecimal amount) {
+ return !BAD_CREDIT.equals( getCredit() )
+ && creditLimit != null
+ && creditLimit.compareTo( amount ) >= 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+ return id == ( ( CustomerTwo ) o ).id;
+ }
+
+ @Override
+ public int hashCode() {
+ return new Integer( id ).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return this.getFirstName() + " " + this.getLastName();
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml
new file mode 100644
index 0000000000..511abfbb59
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml
new file mode 100644
index 0000000000..259e3cba10
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/e1/b/specjmapid/lazy/order_orm.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java
index 86fb4e3987..a74643867b 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/EmbeddableIntegratorTest.java
@@ -26,23 +26,20 @@ package org.hibernate.test.annotations.embeddables;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
-import java.util.LinkedHashSet;
import java.util.List;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.exception.GenericJDBCException;
-import org.hibernate.integrator.internal.IntegratorServiceImpl;
-import org.hibernate.integrator.spi.Integrator;
-import org.hibernate.integrator.spi.IntegratorService;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.internal.BootstrapServiceRegistryImpl;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
@@ -50,6 +47,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Chris Pheby
*/
+@RequiresDialect(H2Dialect.class)
public class EmbeddableIntegratorTest extends BaseUnitTestCase {
/**
@@ -58,7 +56,7 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase {
@Test(expected=GenericJDBCException.class)
public void testWithoutIntegrator() {
- ServiceRegistry reg = new ServiceRegistryBuilder(new BootstrapServiceRegistryImpl())
+ ServiceRegistry reg = new StandardServiceRegistryBuilder(new BootstrapServiceRegistryImpl())
.buildServiceRegistry();
SessionFactory sf = new Configuration()
@@ -82,15 +80,9 @@ public class EmbeddableIntegratorTest extends BaseUnitTestCase {
@Test
public void testWithIntegrator() {
-
- LinkedHashSet providedIntegrators = new LinkedHashSet();
- providedIntegrators.add(new InvestorIntegrator());
- ClassLoaderService classLoaderService = new ClassLoaderServiceImpl();
- IntegratorService integratorService = new IntegratorServiceImpl(providedIntegrators, classLoaderService);
-
- ServiceRegistry reg = new ServiceRegistryBuilder(new BootstrapServiceRegistryImpl(
- classLoaderService,
- integratorService)).buildServiceRegistry();
+ ServiceRegistry reg = new StandardServiceRegistryBuilder(
+ new BootstrapServiceRegistryBuilder().with( new InvestorIntegrator() ).build()
+ ).buildServiceRegistry();
SessionFactory sf = new Configuration()
.addAnnotatedClass( Investor.class )
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java
index 062f862f7d..e8a36f10ca 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embeddables/nested/NestedEmbeddableMetadataTest.java
@@ -23,7 +23,11 @@
*/
package org.hibernate.test.annotations.embeddables.nested;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Test;
@@ -37,6 +41,7 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.type.CustomType;
+import static org.hibernate.testing.junit4.ExtraAssertions.assertJdbcTypeCode;
import static org.junit.Assert.assertEquals;
/**
@@ -57,6 +62,6 @@ public class NestedEmbeddableMetadataTest extends BaseUnitTestCase {
CustomType currencyType = (CustomType) currencyMetadata.getType();
int[] currencySqlTypes = currencyType.sqlTypes( mapping );
assertEquals( 1, currencySqlTypes.length );
- assertEquals( Types.VARCHAR, currencySqlTypes[0] );
+ assertJdbcTypeCode( Types.VARCHAR, currencySqlTypes[0] );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java
index bbbd76dba3..02c68c5d48 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/secondarytable/User.java
@@ -11,13 +11,14 @@ import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.SqlFragmentAlias;
+import org.hibernate.annotations.Type;
@Entity
-@Table(name="USER")
+@Table(name="T_USER")
@SecondaryTable(name="SECURITY_USER")
@FilterDef(name="ageFilter", parameters=@ParamDef(name="age", type="integer"))
@Filter(name="ageFilter", condition="{u}.AGE < :age AND {s}.LOCKED_OUT <> 1",
- aliases={@SqlFragmentAlias(alias="u", table="USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")})
+ aliases={@SqlFragmentAlias(alias="u", table="T_USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")})
public class User {
@Id
@@ -31,13 +32,14 @@ public class User {
@Column(name="AGE")
private int age;
- @Column(name="USERNAME", table="SECURITY_USER")
+ @Column(name="SECURITY_USERNAME", table="SECURITY_USER")
private String username;
- @Column(name="PASSWORD", table="SECURITY_USER")
+ @Column(name="SECURITY_PASSWORD", table="SECURITY_USER")
private String password;
@Column(name="LOCKED_OUT", table="SECURITY_USER")
+ @Type( type = "numeric_boolean")
private boolean lockedOut;
public int getId() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java
index 0db20e43d6..a77e8f3c6b 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/joined/Mammal.java
@@ -6,6 +6,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.Type;
@Entity
@Table(name="ZOOLOGY_MAMMAL")
@@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
public class Mammal extends Animal{
@Column(name="IS_PREGNANT")
+ @Type( type="numeric_boolean" )
private boolean isPregnant;
public boolean isPregnant() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java
index 47f0f72310..483bcc5e2d 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/singletable/Mammal.java
@@ -6,6 +6,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.Type;
@Entity
@Table(name="ZOOLOGY_MAMMAL")
@@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
public class Mammal extends Animal{
@Column(name="IS_PREGNANT")
+ @Type( type="numeric_boolean" )
private boolean isPregnant;
public boolean isPregnant() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java
index 7e4af107fa..23e1b374af 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/filter/subclass/tableperclass/Mammal.java
@@ -6,6 +6,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.Type;
@Entity
@Table(name="ZOOLOGY_MAMMAL")
@@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
public class Mammal extends Animal{
@Column(name="IS_PREGNANT")
+ @Type( type="numeric_boolean" )
private boolean isPregnant;
public boolean isPregnant() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java
index e53ab9efb2..641ccffb08 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java
@@ -6,12 +6,15 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.mapping.Table;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.test.annotations.id.sequences.entities.HibernateSequenceEntity;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@@ -19,6 +22,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@TestForIssue(jiraKey = "HHH-6068")
+@RequiresDialect( value = H2Dialect.class)
public class HibernateSequenceTest extends BaseCoreFunctionalTestCase {
private static final String SCHEMA_NAME = "OTHER_SCHEMA";
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java
new file mode 100644
index 0000000000..879e66766b
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/EntitySerialize.java
@@ -0,0 +1,44 @@
+package org.hibernate.test.annotations.lob;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+import org.hibernate.annotations.TypeDefs;
+
+/**
+ * @author Janario Oliveira
+ */
+@Entity
+@TypeDefs({ @TypeDef(typeClass = ImplicitSerializableType.class, defaultForType = ImplicitSerializable.class) })
+public class EntitySerialize {
+ @Id
+ @GeneratedValue
+ long id;
+
+ @Lob
+ ExplicitSerializable explicitLob;
+
+ @Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType")
+ ExplicitSerializable explicit;
+
+ ImplicitSerializable implicit;
+
+ @Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType")
+ ImplicitSerializable explicitOverridingImplicit;
+
+ /**
+ * common in ExplicitSerializable and ImplicitSerializable to create same property in both
+ * This property will not persist it have a default value per type
+ *
+ * @author Janario Oliveira
+ */
+ public interface CommonSerializable {
+ String getDefaultValue();
+
+ void setDefaultValue(String defaultValue);
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java
new file mode 100644
index 0000000000..75f15d48e3
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializable.java
@@ -0,0 +1,23 @@
+package org.hibernate.test.annotations.lob;
+
+import java.io.Serializable;
+
+import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
+
+/**
+ * @author Janario Oliveira
+ */
+public class ExplicitSerializable implements Serializable, CommonSerializable {
+ String defaultValue;
+ String value;
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java
new file mode 100644
index 0000000000..13effc1804
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ExplicitSerializableType.java
@@ -0,0 +1,30 @@
+package org.hibernate.test.annotations.lob;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
+import org.hibernate.type.SerializableToBlobType;
+
+/**
+ * @author Janario Oliveira
+ */
+public class ExplicitSerializableType extends SerializableToBlobType {
+ @Override
+ public Object get(ResultSet rs, String name) throws SQLException {
+ CommonSerializable deserialize = (CommonSerializable) super.get( rs, name );
+ deserialize.setDefaultValue( "EXPLICIT" );
+ return deserialize;
+ }
+
+ @Override
+ public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
+ if ( value != null ) {
+ ( (CommonSerializable) value ).setDefaultValue( null );
+ }
+ super.set( st, value, index, session );
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java
new file mode 100644
index 0000000000..7f5a894048
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializable.java
@@ -0,0 +1,23 @@
+package org.hibernate.test.annotations.lob;
+
+import java.io.Serializable;
+
+import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
+
+/**
+ * @author Janario Oliveira
+ */
+public class ImplicitSerializable implements Serializable, CommonSerializable {
+ String defaultValue;
+ String value;
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java
new file mode 100644
index 0000000000..c88fb14dea
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/ImplicitSerializableType.java
@@ -0,0 +1,31 @@
+package org.hibernate.test.annotations.lob;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
+import org.hibernate.type.SerializableToBlobType;
+
+/**
+ * @author Janario Oliveira
+ */
+public class ImplicitSerializableType extends SerializableToBlobType {
+
+ @Override
+ public Object get(ResultSet rs, String name) throws SQLException {
+ CommonSerializable deserialize = (CommonSerializable) super.get( rs, name );
+ deserialize.setDefaultValue( "IMPLICIT" );
+ return deserialize;
+ }
+
+ @Override
+ public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
+ if ( value != null ) {
+ ( (CommonSerializable) value ).setDefaultValue( null );
+ }
+ super.set( st, value, index, session );
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java
new file mode 100644
index 0000000000..6d82206a78
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/lob/SerializableToBlobTypeTest.java
@@ -0,0 +1,89 @@
+package org.hibernate.test.annotations.lob;
+
+import static org.junit.Assert.assertEquals;
+
+import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+import org.hibernate.type.SerializableToBlobType;
+import org.hibernate.type.Type;
+import org.junit.Test;
+
+/**
+ * Test type definition for SerializableToBlobType
+ *
+ * @author Janario Oliveira
+ */
+public class SerializableToBlobTypeTest extends BaseCoreFunctionalTestCase {
+ @Test
+ public void testTypeDefinition() {
+ Configuration cfg = configuration();
+ PersistentClass pc = cfg.getClassMapping( EntitySerialize.class.getName() );
+
+ // explicitLob of SerializableToBlobType
+ Type explicitLobType = pc.getProperty( "explicitLob" ).getType();
+ assertEquals( ExplicitSerializable.class, explicitLobType.getReturnedClass() );
+ assertEquals( SerializableToBlobType.class.getName(), explicitLobType.getName() );
+
+ // explicit of ExplicitSerializableType
+ Type explicitType = pc.getProperty( "explicit" ).getType();
+ assertEquals( ExplicitSerializable.class, explicitType.getReturnedClass() );
+ assertEquals( ExplicitSerializableType.class.getName(), explicitType.getName() );
+
+ // implicit of ImplicitSerializableType
+ Type implicitType = pc.getProperty( "implicit" ).getType();
+ assertEquals( ImplicitSerializable.class, implicitType.getReturnedClass() );
+ assertEquals( ImplicitSerializableType.class.getName(), implicitType.getName() );
+
+ // explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType
+ Type overrideType = pc.getProperty( "explicitOverridingImplicit" ).getType();
+ assertEquals( ImplicitSerializable.class, overrideType.getReturnedClass() );
+ assertEquals( ExplicitSerializableType.class.getName(), overrideType.getName() );
+ }
+
+ @Test
+ public void testPersist() {
+ EntitySerialize entitySerialize = new EntitySerialize();
+
+ entitySerialize.explicitLob = new ExplicitSerializable();
+ entitySerialize.explicitLob.value = "explicitLob";
+ entitySerialize.explicitLob.defaultValue = "defaultExplicitLob";
+
+ entitySerialize.explicit = new ExplicitSerializable();
+ entitySerialize.explicit.value = "explicit";
+
+ entitySerialize.implicit = new ImplicitSerializable();
+ entitySerialize.implicit.value = "implicit";
+
+ entitySerialize.explicitOverridingImplicit = new ImplicitSerializable();
+ entitySerialize.explicitOverridingImplicit.value = "explicitOverridingImplicit";
+
+ Session session = openSession();
+ session.getTransaction().begin();
+ session.persist( entitySerialize );
+
+ session.getTransaction().commit();
+ session.close();
+
+ session = openSession();
+
+ EntitySerialize persistedSerialize = (EntitySerialize) session.get( EntitySerialize.class, entitySerialize.id );
+ assertEquals( "explicitLob", persistedSerialize.explicitLob.value );
+ assertEquals( "explicit", persistedSerialize.explicit.value );
+ assertEquals( "implicit", persistedSerialize.implicit.value );
+ assertEquals( "explicitOverridingImplicit", persistedSerialize.explicitOverridingImplicit.value );
+
+ assertEquals( "defaultExplicitLob", persistedSerialize.explicitLob.defaultValue );
+ assertEquals( "EXPLICIT", persistedSerialize.explicit.defaultValue );
+ assertEquals( "IMPLICIT", persistedSerialize.implicit.defaultValue );
+ assertEquals( "EXPLICIT", persistedSerialize.explicitOverridingImplicit.defaultValue );
+
+ session.close();
+ }
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[] { EntitySerialize.class };
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
index 29fc4a99ed..9fcda3079f 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
@@ -316,7 +316,55 @@ public class ManyToManyTest
tx.rollback();
s.close();
}
+
+ // HHH-4394
+ @Test
+ public void testOrderByContractor() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ // create some test entities
+ Employer employer = new Employer();
+ Contractor contractor1 = new Contractor();
+ contractor1.setName( "Emmanuel" );
+ contractor1.setHourlyRate(100.0f);
+ Contractor contractor2 = new Contractor();
+ contractor2.setName( "Hardy" );
+ contractor2.setHourlyRate(99.99f);
+ s.persist( contractor1 );
+ s.persist( contractor2 );
+
+ // add contractors to employer
+ List setOfContractors = new ArrayList();
+ setOfContractors.add( contractor1 );
+ setOfContractors.add( contractor2 );
+ employer.setContractors( setOfContractors );
+
+ // add employer to contractors
+ Collection employerListContractor1 = new ArrayList();
+ employerListContractor1.add( employer );
+ contractor1.setEmployers( employerListContractor1 );
+
+ Collection employerListContractor2 = new ArrayList();
+ employerListContractor2.add( employer );
+ contractor2.setEmployers( employerListContractor2 );
+
+ s.flush();
+ s.clear();
+
+ // assertions
+ employer = (Employer) s.get( Employer.class, employer.getId() );
+ assertNotNull( employer );
+ assertNotNull( employer.getContractors() );
+ assertEquals( 2, employer.getContractors().size() );
+ Contractor firstContractorFromDb = (Contractor) employer.getContractors().iterator().next();
+ assertEquals( contractor2.getName(), firstContractorFromDb.getName() );
+ tx.rollback();
+ s.close();
+ }
+
@Test
public void testRemoveInBetween() throws Exception {
Session s;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/cache/InsertedDataTest.java b/hibernate-core/src/test/java/org/hibernate/test/cache/InsertedDataTest.java
index 32d64c5159..5e8693e999 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/cache/InsertedDataTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/cache/InsertedDataTest.java
@@ -28,9 +28,9 @@ import java.util.Map;
import org.junit.Test;
import org.hibernate.Session;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
@@ -58,7 +58,7 @@ public class InsertedDataTest extends BaseCoreFunctionalTestCase {
}
@Override
- protected void prepareBasicRegistryBuilder(ServiceRegistryBuilder serviceRegistryBuilder) {
+ protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
serviceRegistryBuilder.applySetting( Environment.CACHE_REGION_PREFIX, "" );
serviceRegistryBuilder.applySetting( Environment.GENERATE_STATISTICS, "true" );
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java
new file mode 100644
index 0000000000..6b66ce94f7
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/cfg/WrongCircularityDetectionTest.java
@@ -0,0 +1,74 @@
+package org.hibernate.test.cfg;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseUnitTestCase;
+import org.junit.Test;
+
+/**
+ * This test illustrates the problem when two related (in terms of joins)
+ * classes have the same table name in different schemas.
+ *
+ * @author Didier Villevalois
+ */
+@TestForIssue(jiraKey = "HHH-7134")
+public class WrongCircularityDetectionTest extends BaseUnitTestCase {
+
+ @Test
+ public void testNoCircularityDetection() {
+ Configuration cfg = new Configuration();
+ cfg.addAnnotatedClass(Entity1.class);
+ cfg.addAnnotatedClass(Entity2.class);
+
+ cfg.buildMappings();
+
+ org.hibernate.mapping.Table entity1Table = cfg.getClassMapping(
+ Entity1.class.getName()).getTable();
+ org.hibernate.mapping.Table entity2Table = cfg.getClassMapping(
+ Entity2.class.getName()).getTable();
+
+ assertTrue(entity1Table.getName().equals(entity2Table.getName()));
+ assertFalse(entity1Table.getSchema().equals(entity2Table.getSchema()));
+ }
+
+ @Entity
+ @Inheritance(strategy = InheritanceType.JOINED)
+ @Table(schema = "schema1", name = "entity")
+ public static class Entity1 {
+ private String id;
+
+ @Id
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+ }
+
+ @Entity
+ @Table(schema = "schema2", name = "entity")
+ public static class Entity2 extends Entity1 {
+ private String value;
+
+ @Basic
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java b/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java
index 177df15ed2..706391588b 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/cfg/persister/PersisterClassProviderTest.java
@@ -24,10 +24,11 @@ import org.junit.Test;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
@@ -42,15 +43,15 @@ public class PersisterClassProviderTest extends BaseUnitTestCase {
Configuration cfg = new Configuration();
cfg.addAnnotatedClass( Gate.class );
- ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
+ ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() )
.buildServiceRegistry();
//no exception as the GoofyPersisterClassProvider is not set
SessionFactory sessionFactory = cfg.buildSessionFactory( serviceRegistry );
sessionFactory.close();
- ServiceRegistryBuilder.destroy( serviceRegistry );
+ StandardServiceRegistryBuilder.destroy( serviceRegistry );
- serviceRegistry = new ServiceRegistryBuilder()
+ serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() )
.addService( PersisterClassResolver.class, new GoofyPersisterClassProvider() )
.buildServiceRegistry();
@@ -69,13 +70,13 @@ public class PersisterClassProviderTest extends BaseUnitTestCase {
);
}
finally {
- ServiceRegistryBuilder.destroy( serviceRegistry );
+ StandardServiceRegistryBuilder.destroy( serviceRegistry );
}
cfg = new Configuration();
cfg.addAnnotatedClass( Portal.class );
cfg.addAnnotatedClass( Window.class );
- serviceRegistry = new ServiceRegistryBuilder()
+ serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() )
.addService( PersisterClassResolver.class, new GoofyPersisterClassProvider() )
.buildServiceRegistry();
@@ -91,14 +92,14 @@ public class PersisterClassProviderTest extends BaseUnitTestCase {
( (GoofyException) e.getCause() ).getValue() );
}
finally {
- ServiceRegistryBuilder.destroy( serviceRegistry );
+ StandardServiceRegistryBuilder.destroy( serviceRegistry );
}
cfg = new Configuration();
cfg.addAnnotatedClass( Tree.class );
cfg.addAnnotatedClass( Palmtree.class );
- serviceRegistry = new ServiceRegistryBuilder()
+ serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() )
.addService( PersisterClassResolver.class, new GoofyPersisterClassProvider() )
.buildServiceRegistry();
@@ -114,7 +115,7 @@ public class PersisterClassProviderTest extends BaseUnitTestCase {
( (GoofyException) e.getCause() ).getValue() );
}
finally {
- ServiceRegistryBuilder.destroy( serviceRegistry );
+ StandardServiceRegistryBuilder.destroy( serviceRegistry );
}
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java
new file mode 100644
index 0000000000..5dfa28a905
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java
@@ -0,0 +1,105 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collection.map.hhh7557;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.hibernate.Session;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+/**
+ * @author Elizabeth Chatman
+ * @author Steve Ebersole
+ */
+public class EntityMapTest extends BaseCoreFunctionalTestCase {
+ @Override
+ protected Class>[] getAnnotatedClasses() {
+ return new Class[] {MapValue.class, MapKey.class, MapHolder.class};
+ }
+
+ @Test
+ public void testInsertIntoMap() throws Exception {
+ {
+ // Session 1: Insert 3 values into the map
+ Session session = openSession();
+ session.beginTransaction();
+ MapHolder mapHolder = new MapHolder();
+ mapHolder.setMap( new HashMap() );
+ addMapEntry( session, mapHolder, "A", "1" );
+ addMapEntry( session, mapHolder, "B", "2" );
+ addMapEntry( session, mapHolder, "C", "3" );
+ session.save( mapHolder );
+ // Verify there are 3 entries in the map
+ Assert.assertEquals( 3, mapHolder.getMap().size() );
+ session.getTransaction().commit();
+ session.close();
+ }
+
+ {
+ // Session 2: Add a 4th value to the map
+ Session session = openSession();
+ session.beginTransaction();
+ MapHolder mapHolder = getMapHolder( session );
+ System.out.println( "Got MapHolder; checking map size -----" );
+ Assert.assertEquals( 3, mapHolder.getMap().size() );
+ System.out.println( "Got MapHolder; checked map size -----" );
+ addMapEntry( session, mapHolder, "D", "4" );
+ // Verify there are 4 entries in the map
+ Assert.assertEquals( 4, mapHolder.getMap().size() );
+ session.getTransaction().commit();
+ session.close();
+ }
+
+ {
+ // Session 3: Count the entries in the map
+ Session session = openSession();
+ session.beginTransaction();
+ MapHolder mapHolder = getMapHolder( session );
+ // Fails here (expected:<4> but was:<1>)
+ Assert.assertEquals( 4, mapHolder.getMap().size() );
+ session.getTransaction().commit();
+ session.close();
+ }
+ }
+
+ private void addMapEntry(Session session, MapHolder mapHolder, String key, String value) {
+ System.out.println( "Inserting (" + key + "," + value + ") into map" );
+ MapValue entityValue = new MapValue( value );
+ session.save( entityValue );
+ MapKey entityKey = new MapKey( key, entityValue );
+ session.save( entityKey );
+ mapHolder.getMap().put( entityKey, entityValue );
+ }
+
+ private MapHolder getMapHolder(Session session) {
+ List mapHolders = session.createQuery( "select distinct mh from MapHolder mh" ).list();
+ Assert.assertEquals( 1, mapHolders.size() );
+ return (MapHolder) mapHolders.get( 0 );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java
new file mode 100644
index 0000000000..6055c7f2e9
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java
@@ -0,0 +1,80 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collection.map.hhh7557;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.MapKeyJoinColumn;
+import javax.persistence.Table;
+import java.util.Map;
+
+/**
+ * @author Elizabeth Chatman
+ * @author Steve Ebersole
+ */
+@Entity
+@Table(name = "map_holder")
+public class MapHolder {
+ private Long id;
+ private Map map;
+
+ @Id
+ @GeneratedValue
+ @Column(name = "id", unique = true, nullable = false)
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @ManyToMany
+ @JoinTable(
+ name = "map_key_map_value",
+ joinColumns = @JoinColumn(name = "map_holder_id", nullable = false),
+ inverseJoinColumns = @JoinColumn(name = "map_value_id", nullable = false)
+ )
+ @MapKeyJoinColumn(name = "map_key_id", nullable = false)
+ public Map getMap() {
+ return map;
+ }
+
+ public void setMap(Map map) {
+ this.map = map;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append( "MapHolder [id=" ).append( id ).append( "]" );
+ return builder.toString();
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java
new file mode 100644
index 0000000000..3bba1a0ae1
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java
@@ -0,0 +1,154 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collection.map.hhh7557;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author Elizabeth Chatman
+ * @author Steve Ebersole
+ */
+@Entity
+@Table(name = "map_key", uniqueConstraints = {
+ @UniqueConstraint(columnNames = {"name", "default_map_value_id"})
+})
+public class MapKey {
+ private static final Logger log = Logger.getLogger( MapKey.class );
+
+ private Long id;
+ private String name;
+ private MapValue defaultValue;
+
+ public MapKey() {
+ }
+
+ public MapKey(String name, MapValue defaultValue) {
+ this.name = name;
+ this.defaultValue = defaultValue;
+ }
+
+ @Id
+ @GeneratedValue
+ @Column(name = "id", unique = true, nullable = false)
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Column(name = "name", nullable = false)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ log.tracef( "Setting name : %s", name );
+ this.name = name;
+ }
+
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "default_map_value_id", nullable = false)
+ public MapValue getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(MapValue defaultValue) {
+ log.tracef( "Setting defaultValue : %s", defaultValue );
+ this.defaultValue = defaultValue;
+ }
+
+ private int previousHashCode = -1;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getDefaultValue() == null) ? 0 : getDefaultValue().hashCode());
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ log.tracef(
+ "Calculated hashcode [%s] = %s (previous=%s, changed?=%s)",
+ this,
+ result,
+ previousHashCode,
+ !(previousHashCode == -1 || previousHashCode == result)
+ );
+ previousHashCode = result;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ log.tracef( "Checking equality : %s -> %s", this, obj );
+ if ( this == obj ) {
+ return true;
+ }
+ if ( obj == null ) {
+ return false;
+ }
+ if ( !(obj instanceof MapKey) ) {
+ return false;
+ }
+ MapKey other = (MapKey) obj;
+ if ( getDefaultValue() == null ) {
+ if ( other.getDefaultValue() != null ) {
+ return false;
+ }
+ }
+ else if ( !getDefaultValue().equals( other.getDefaultValue() ) ) {
+ return false;
+ }
+ if ( getName() == null ) {
+ if ( other.getName() != null ) {
+ return false;
+ }
+ }
+ else if ( !getName().equals( other.getName() ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append( "MapKey [id=" ).append( getId() )
+ .append( ", name=" ).append( getName() )
+ .append( ", defaultValue=" ).append( getDefaultValue() )
+ .append( "]" );
+ return builder.toString();
+ }
+
+}
\ No newline at end of file
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java
new file mode 100644
index 0000000000..0a1c1473d7
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java
@@ -0,0 +1,123 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collection.map.hhh7557;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author Elizabeth Chatman
+ * @author Steve Ebersole
+ */
+@Entity
+@Table(name = "map_value")
+public class MapValue {
+ private static final Logger log = Logger.getLogger( MapValue.class );
+
+ private Long id;
+ private String name;
+
+ public MapValue() {
+ }
+
+ public MapValue(String name) {
+ this.name = name;
+ }
+
+ @Id
+ @GeneratedValue
+ @Column(name = "id", unique = true, nullable = false)
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Column(name = "name", unique = true, nullable = false)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ log.tracef( "Setting name : %s", name );
+ this.name = name;
+ }
+
+ int previousHashCode = -1;
+
+ @Override
+ public int hashCode() {
+
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+ log.tracef(
+ "Calculated hashcode [%s] = %s (previous=%s, changed?=%s)",
+ this,
+ result,
+ previousHashCode,
+ !(previousHashCode == -1 || previousHashCode == result)
+ );
+ previousHashCode = result;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ log.tracef( "Checking equality : %s -> %s", this, obj );
+ if ( this == obj ) {
+ return true;
+ }
+ if ( obj == null ) {
+ return false;
+ }
+ if ( !(obj instanceof MapValue) ) {
+ return false;
+ }
+ MapValue other = (MapValue) obj;
+ if ( getName() == null ) {
+ if ( other.getName() != null ) {
+ return false;
+ }
+ }
+ else if ( !getName().equals( other.getName() ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append( "MapValue [id=" ).append( getId() ).append( ", name=" ).append( getName() ).append( "]" );
+ return builder.toString();
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java
new file mode 100644
index 0000000000..73aaa4ced1
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ATable.java
@@ -0,0 +1,119 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collectionalias;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+/**
+ * @author Dave Stephan
+ */
+@Entity
+public class ATable implements Serializable
+{
+ private Integer firstId;
+
+ private List tablebs = new ArrayList();
+
+ public ATable()
+ {
+ }
+
+ /** minimal constructor */
+ public ATable(Integer firstId)
+ {
+ this.firstId = firstId;
+ }
+
+ @Id
+ @Column(name = "idcolumn", nullable = false)
+ public Integer getFirstId()
+ {
+ return this.firstId;
+ }
+
+ public void setFirstId(Integer firstId)
+ {
+ this.firstId = firstId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((firstId == null) ? 0 : firstId.hashCode());
+ result = prime * result + ((tablebs == null) ? 0 : tablebs.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ATable other = (ATable) obj;
+ if (firstId == null)
+ {
+ if (other.firstId != null)
+ return false;
+ }
+ else if (!firstId.equals(other.firstId))
+ return false;
+ if (tablebs == null)
+ {
+ if (other.tablebs != null)
+ return false;
+ }
+ else if (!tablebs.equals(other.tablebs))
+ return false;
+ return true;
+ }
+
+
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tablea")
+ public List getTablebs()
+ {
+ return tablebs;
+ }
+
+ public void setTablebs(List tablebs)
+ {
+ this.tablebs = tablebs;
+ }
+
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java
new file mode 100644
index 0000000000..ac1c1e9c58
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/CollectionAliasTest.java
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collectionalias;
+
+import org.junit.Test;
+
+import org.hibernate.Session;
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+/**
+ * @author Dave Stephan
+ * @author Gail Badner
+ */
+public class CollectionAliasTest extends BaseCoreFunctionalTestCase {
+
+ @TestForIssue( jiraKey = "HHH-7545" )
+ @Test
+ public void test() {
+ Session s = openSession();
+ s.getTransaction().begin();
+ ATable aTable = new ATable( 1 );
+ TableB tableB = new TableB(
+ new TableBId( 1, "a", "b" )
+ );
+ aTable.getTablebs().add( tableB );
+ tableB.setTablea( aTable );
+ s.save( aTable );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ aTable = (ATable) s.createQuery( "select distinct tablea from ATable tablea LEFT JOIN FETCH tablea.tablebs " ).uniqueResult();
+ assertEquals( new Integer( 1 ), aTable.getFirstId() );
+ assertEquals( 1, aTable.getTablebs().size() );
+ tableB = aTable.getTablebs().get( 0 );
+ assertSame( aTable, tableB.getTablea() );
+ assertEquals( new Integer( 1 ), tableB.getId().getFirstId() );
+ assertEquals( "a", tableB.getId().getSecondId() );
+ assertEquals( "b", tableB.getId().getThirdId() );
+ s.close();
+ }
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[] {
+ TableBId.class,
+ TableB.class,
+ TableA.class,
+ ATable.class
+ };
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java
new file mode 100644
index 0000000000..616f528a79
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/ReorderedMappingsCollectionAliasTest.java
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collectionalias;
+
+/**
+ * The bug fixed by HHH-7545 showed showed different results depending on the order
+ * in which entity mappings were processed.
+ *
+ * This mappings are in the opposite order here than in CollectionAliasTest.
+ *
+ * @Author Gail Badner
+ */
+public class ReorderedMappingsCollectionAliasTest extends CollectionAliasTest {
+
+ @Override
+ protected Class[] getAnnotatedClasses() {
+ return new Class[] {
+ ATable.class,
+ TableA.class,
+ TableB.class,
+ TableBId.class,
+ };
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java
new file mode 100644
index 0000000000..685685d1e4
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableA.java
@@ -0,0 +1,113 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collectionalias;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Dave Stephan
+ */
+@Entity
+public class TableA
+{
+ @Id
+ private int id;
+
+ private String test;
+
+ private String test2;
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + id;
+ result = prime * result + ((test == null) ? 0 : test.hashCode());
+ result = prime * result + ((test2 == null) ? 0 : test2.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TableA other = (TableA) obj;
+ if (id != other.id)
+ return false;
+ if (test == null)
+ {
+ if (other.test != null)
+ return false;
+ }
+ else if (!test.equals(other.test))
+ return false;
+ if (test2 == null)
+ {
+ if (other.test2 != null)
+ return false;
+ }
+ else if (!test2.equals(other.test2))
+ return false;
+ return true;
+ }
+
+ public String getTest2()
+ {
+ return test2;
+ }
+
+ public void setTest2(String test2)
+ {
+ this.test2 = test2;
+ }
+
+ public String getTest()
+ {
+ return test;
+ }
+
+ public void setTest(String test)
+ {
+ this.test = test;
+ }
+
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId(int id)
+ {
+ this.id = id;
+ }
+
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java
new file mode 100644
index 0000000000..677d44e905
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableB.java
@@ -0,0 +1,118 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collectionalias;
+
+import java.io.Serializable;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+
+/**
+ * @author Dave Stephan
+ */
+@Entity
+public class TableB implements Serializable
+{
+
+ private TableBId id;
+
+ private ATable tablea;
+
+ public TableB() {
+ }
+
+ /** full constructor */
+ public TableB(TableBId id) {
+ this.id = id;
+ }
+
+ // Property accessors
+ @EmbeddedId
+ @AttributeOverrides( {
+ @AttributeOverride(name = "firstId", column = @Column(name = "idcolumn", nullable = false)),
+ @AttributeOverride(name = "secondId", column = @Column(name = "idcolumn_second", nullable = false, length = 50)),
+ @AttributeOverride(name = "thirdId", column = @Column(name = "thirdcolumn", nullable = false, length = 20)) })
+ public TableBId getId() {
+ return this.id;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((tablea == null) ? 0 : tablea.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TableB other = (TableB) obj;
+ if (id == null)
+ {
+ if (other.id != null)
+ return false;
+ }
+ else if (!id.equals(other.id))
+ return false;
+ if (tablea == null)
+ {
+ if (other.tablea != null)
+ return false;
+ }
+ else if (!tablea.equals(other.tablea))
+ return false;
+ return true;
+ }
+
+ public void setId(TableBId id) {
+ this.id = id;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumns( { @JoinColumn(name = "idcolumn", referencedColumnName = "idcolumn", nullable = false, insertable = false, updatable = false) })
+ public ATable getTablea() {
+ return tablea;
+ }
+
+ public void setTablea(ATable tablea) {
+ this.tablea = tablea;
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java
new file mode 100644
index 0000000000..3623c7718a
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/collectionalias/TableBId.java
@@ -0,0 +1,133 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.collectionalias;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+/**
+ * @author Dave Stephan
+ */
+@Embeddable
+public class TableBId implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ // Fields
+
+ private Integer firstId;
+
+ private String secondId;
+
+ private String thirdId;
+
+ // Constructors
+
+ /** default constructor */
+ public TableBId() {
+ }
+
+ /** full constructor */
+ public TableBId(Integer firstId, String secondId, String thirdId) {
+ this.firstId = firstId;
+ this.secondId = secondId;
+ this.thirdId = thirdId;
+ }
+
+ // Property accessors
+
+ @Column(name = "idcolumn", nullable = false)
+ public Integer getFirstId() {
+ return this.firstId;
+ }
+
+ public void setFirstId(Integer firstId) {
+ this.firstId = firstId;
+ }
+
+ @Column(name = "idcolumn_second", nullable = false, length = 50)
+ public String getSecondId() {
+ return this.secondId;
+ }
+
+ public void setSecondId(String secondId) {
+ this.secondId = secondId;
+ }
+
+ @Column(name = "thirdcolumn", nullable = false, length = 50)
+ public String getThirdId() {
+ return this.thirdId;
+ }
+
+ public void setThirdId(String thirdId) {
+ this.thirdId = thirdId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((firstId == null) ? 0 : firstId.hashCode());
+ result = prime * result + ((secondId == null) ? 0 : secondId.hashCode());
+ result = prime * result + ((thirdId == null) ? 0 : thirdId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TableBId other = (TableBId) obj;
+ if (firstId == null)
+ {
+ if (other.firstId != null)
+ return false;
+ }
+ else if (!firstId.equals(other.firstId))
+ return false;
+ if (secondId == null)
+ {
+ if (other.secondId != null)
+ return false;
+ }
+ else if (!secondId.equals(other.secondId))
+ return false;
+ if (thirdId == null)
+ {
+ if (other.thirdId != null)
+ return false;
+ }
+ else if (!thirdId.equals(other.thirdId))
+ return false;
+ return true;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java
index 8bc8c1c12b..8b153b6b1b 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/common/BasicTestingJdbcServiceImpl.java
@@ -29,6 +29,7 @@ import java.util.Set;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.internal.ResultSetWrapperImpl;
import org.hibernate.engine.jdbc.internal.TypeInfo;
import org.hibernate.engine.jdbc.spi.JdbcServices;
@@ -36,7 +37,6 @@ import org.hibernate.engine.jdbc.spi.ResultSetWrapper;
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.metamodel.spi.relational.Identifier;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.env.internal.ExtractedDatabaseMetaDataImpl;
import org.hibernate.service.jdbc.env.internal.LobCreatorBuilderImpl;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java
index d1080faed0..68895887ca 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/common/JdbcConnectionAccessImpl.java
@@ -26,9 +26,9 @@ package org.hibernate.test.common;
import java.sql.Connection;
import java.sql.SQLException;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
/**
diff --git a/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java b/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java
index 41e8f596a4..be0ed8f3a5 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/common/TransactionEnvironmentImpl.java
@@ -30,7 +30,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.stat.internal.ConcurrentStatisticsImpl;
import org.hibernate.stat.spi.StatisticsImplementor;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java
index 04e428fe54..c63131040e 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java
@@ -1,35 +1,38 @@
// $Id: AggressiveReleaseTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
package org.hibernate.test.connections;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.junit.Test;
-
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.internal.util.SerializationHelper;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.Test;
/**
* Implementation of AggressiveReleaseTest.
*
* @author Steve Ebersole
*/
+@RequiresDialect(H2Dialect.class)
public class AggressiveReleaseTest extends ConnectionManagementTestCase {
@Override
public void configure(Configuration cfg) {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java
index c297fd862d..a147c0e3b2 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/connections/BasicConnectionProviderTest.java
@@ -27,12 +27,15 @@ import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.testing.RequiresDialect;
/**
* Implementation of BasicConnectionProviderTest.
*
* @author Steve Ebersole
*/
+@RequiresDialect(H2Dialect.class)
public class BasicConnectionProviderTest extends ConnectionManagementTestCase {
@Override
protected Session getSessionUnderTest() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java b/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
index 9a7f9b404c..ba3a685f27 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java
@@ -27,6 +27,7 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.internal.util.SerializationHelper;
+
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@@ -46,6 +47,7 @@ import static org.junit.Assert.fail;
*
* @author Steve Ebersole
*/
+
public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTestCase {
@Override
public final String[] getMappings() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java
index 7caa8d8ecb..380795baa5 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/connections/CurrentSessionConnectionTest.java
@@ -24,12 +24,15 @@
package org.hibernate.test.connections;
import org.hibernate.Session;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.testing.RequiresDialect;
/**
* Implementation of CurrentSessionConnectionTest.
*
* @author Steve Ebersole
*/
+@RequiresDialect(H2Dialect.class)
public class CurrentSessionConnectionTest extends AggressiveReleaseTest {
@Override
protected Session getSessionUnderTest() throws Throwable {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java
index 103665315a..b329a6a0e3 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java
@@ -31,11 +31,13 @@ import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.testing.AfterClassOnce;
import org.hibernate.testing.BeforeClassOnce;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.tool.hbm2ddl.SchemaExport;
@@ -44,6 +46,7 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
*
* @author Steve Ebersole
*/
+@RequiresDialect(H2Dialect.class)
public class SuppliedConnectionTest extends ConnectionManagementTestCase {
private ConnectionProvider cp = ConnectionProviderBuilder.buildConnectionProvider();
private Connection connectionUnderTest;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
index 6162119056..cc7797b1bd 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java
@@ -30,9 +30,11 @@ import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.context.internal.ThreadLocalSessionContext;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.spi.LocalStatus;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
+import org.hibernate.testing.RequiresDialect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -42,6 +44,7 @@ import static org.junit.Assert.fail;
/**
* @author Steve Ebersole
*/
+@RequiresDialect(H2Dialect.class)
public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase {
@Override
public void configure(Configuration cfg) {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java
index e7f7c6ddda..cb299f9a7a 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/LongInElementsTest.java
@@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
@@ -22,11 +22,11 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.criteria;
+import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
-
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
@@ -34,13 +34,13 @@ import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TeradataDialect;
import org.hibernate.test.hql.StateProvince;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.Test;
/**
* HHH-2166 Long "in" lists in queries results in a Java stack overflow
@@ -60,7 +60,7 @@ public class LongInElementsTest extends BaseCoreFunctionalTestCase {
@Test
@TestForIssue( jiraKey = "HHH-2166" )
@SkipForDialect(
- value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class },
+ value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class, SybaseDialect.class },
comment = "this test fails on oracle and ms sql server, for more info, see HHH-1123"
)
public void testLongInElementsByHQL() {
@@ -90,7 +90,7 @@ public class LongInElementsTest extends BaseCoreFunctionalTestCase {
@Test
@TestForIssue( jiraKey = "HHH-2166" )
@SkipForDialect(
- value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class },
+ value = { SQLServerDialect.class, Oracle8iDialect.class, TeradataDialect.class, SybaseDialect.class },
comment = "this test fails on oracle and ms sql server, for more info, see HHH-1123"
)
public void testLongInElementsByCriteria() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java
new file mode 100644
index 0000000000..a26dd02205
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/enums/InvalidEnumeratedJavaTypeTest.java
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.enums;
+
+import javax.persistence.Entity;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.cfg.Configuration;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseUnitTestCase;
+
+import static org.junit.Assert.fail;
+
+/**
+ * @author Steve Ebersole
+ */
+public class InvalidEnumeratedJavaTypeTest extends BaseUnitTestCase {
+ @Test
+ public void testInvalidMapping() {
+ final Configuration cfg = new Configuration();
+ try {
+ cfg.addAnnotatedClass( TheEntity.class );
+ cfg.buildMappings();
+ fail( "Was expecting failure" );
+ }
+ catch (AnnotationException expected) {
+ System.out.println( expected );
+ }
+ }
+
+ @Entity
+ public static class TheEntity {
+ @Id private Long id;
+ @Enumerated private Boolean yesNo;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java b/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java
index 4ec9633906..0d13e5d33c 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.service.spi.EventListenerRegistry;
@@ -38,7 +39,6 @@ import org.hibernate.event.spi.DeleteEventListener;
import org.hibernate.event.spi.EventType;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java b/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java
index bb7a228b18..d4ce19796c 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/extendshbm/ExtendsTest.java
@@ -7,7 +7,7 @@ import org.junit.Test;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java
new file mode 100644
index 0000000000..8fdf82ba2e
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/Employee.java
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.fetchprofiles.join.selfReferencing;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.hibernate.annotations.FetchMode;
+import org.hibernate.annotations.FetchProfile;
+import org.hibernate.annotations.FetchProfiles;
+
+/**
+ * @author Steve Ebersole
+ */
+@Entity
+@FetchProfiles(
+ @FetchProfile(
+ name = Employee.FETCH_PROFILE_TREE,
+ fetchOverrides = {
+ @FetchProfile.FetchOverride(entity = Employee.class, association = "manager", mode = FetchMode.JOIN),
+ @FetchProfile.FetchOverride(entity = Employee.class, association = "minions", mode = FetchMode.JOIN)
+ }
+ )
+)
+public class Employee {
+ public final static String FETCH_PROFILE_TREE = "locationTree";
+
+ private Long id;
+ private Employee manager;
+ private Collection minions = new ArrayList();
+
+ @Id
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "manager_id")
+ public Employee getManager() {
+ return manager;
+ }
+
+ public void setManager(Employee manager) {
+ this.manager = manager;
+ }
+
+ @OneToMany(mappedBy = "manager", fetch = FetchType.LAZY)
+ public Collection getMinions() {
+ return minions;
+ }
+
+ public void setMinions(Collection minions) {
+ this.minions = minions;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java
new file mode 100644
index 0000000000..2cd272d41f
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/selfReferencing/JoinSelfReferentialFetchProfileTest.java
@@ -0,0 +1,53 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.fetchprofiles.join.selfReferencing;
+
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+/**
+ * @author Steve Ebersole
+ */
+public class JoinSelfReferentialFetchProfileTest extends BaseCoreFunctionalTestCase {
+ @Override
+ protected Class>[] getAnnotatedClasses() {
+ return new Class[] { Employee.class };
+ }
+
+ @Test
+ public void testEnablingJoinFetchProfileAgainstSelfReferentialAssociation() {
+ Session s = openSession();
+ s.beginTransaction();
+ s.enableFetchProfile( Employee.FETCH_PROFILE_TREE );
+ s.createCriteria( Employee.class )
+ .add( Restrictions.isNull( "manager" ) )
+ .list();
+ s.getTransaction().commit();
+ s.close();
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java
index 516b659e86..793749f250 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/fileimport/CommandExtractorServiceTest.java
@@ -23,9 +23,11 @@
*/
package org.hibernate.test.fileimport;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
@@ -34,6 +36,10 @@ import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/
@TestForIssue( jiraKey = "HHH-2403" )
+@RequiresDialect(value = H2Dialect.class,
+ jiraKey = "HHH-6286",
+ comment = "Only running the tests against H2, because the sql statements in the import file are not generic. " +
+ "This test should actually not test directly against the db")
public class CommandExtractorServiceTest extends MultiLineImportFileTest {
@Override
public void configure(Configuration cfg) {
@@ -41,7 +47,7 @@ public class CommandExtractorServiceTest extends MultiLineImportFileTest {
}
@Override
- protected void prepareBasicRegistryBuilder(ServiceRegistryBuilder serviceRegistryBuilder) {
+ protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
super.prepareBasicRegistryBuilder( serviceRegistryBuilder );
serviceRegistryBuilder.addService( ImportSqlCommandExtractor.class, new MultipleLinesSqlCommandExtractor() );
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java b/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java
index 747f89b911..4057f501bf 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/flush/TestAutoFlushBeforeQueryExecution.java
@@ -43,8 +43,8 @@ import org.hibernate.event.spi.PreUpdateEvent;
import org.hibernate.event.spi.PreUpdateEventListener;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.SessionImpl;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java b/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java
index f1864c8f18..861531a0f2 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java
@@ -27,6 +27,7 @@ import org.junit.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.service.spi.EventListenerRegistry;
@@ -35,7 +36,6 @@ import org.hibernate.event.spi.PreUpdateEvent;
import org.hibernate.event.spi.PreUpdateEventListener;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
index 01ce5c0374..fe98879562 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
@@ -72,6 +72,19 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
};
}
+ @Test
+ public void testUpdateWithSubquery() {
+ Session s = openSession();
+ s.beginTransaction();
+
+ // just checking parsing and syntax...
+ s.createQuery( "update Human h set h.bodyWeight = h.bodyWeight + (select count(1) from IntegerVersioned)" ).executeUpdate();
+ s.createQuery( "update Human h set h.bodyWeight = h.bodyWeight + (select count(1) from IntegerVersioned) where h.description = 'abc'" ).executeUpdate();
+
+ s.getTransaction().commit();
+ s.close();
+ }
+
@Test
public void testDeleteNonExistentEntity() {
Session s = openSession();
diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java
new file mode 100644
index 0000000000..3f27d7f9b8
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/JoinedSubclassHierarchyWithIdentityGenerationTest.java
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.idgen.identity.joinedSubClass;
+
+import org.hibernate.Session;
+
+import org.junit.Test;
+
+import org.hibernate.testing.DialectChecks;
+import org.hibernate.testing.RequiresDialectFeature;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+
+/**
+ * @author Andrey Vlasov
+ * @author Steve Ebersole
+ */
+@RequiresDialectFeature( DialectChecks.SupportsIdentityColumns.class )
+public class JoinedSubclassHierarchyWithIdentityGenerationTest extends BaseCoreFunctionalTestCase {
+ @Override
+ protected Class>[] getAnnotatedClasses() {
+ return new Class[] { Sub.class };
+ }
+
+ @Test
+ public void shouldPersistDebtorAccountWhenParentServiceAgreementPersisted() {
+ Session s = openSession();
+ s.beginTransaction();
+ s.save( new Sub() );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ s.createQuery( "delete Sub" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java
new file mode 100644
index 0000000000..db6c9cfc13
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Sub.java
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.idgen.identity.joinedSubClass;
+
+import javax.persistence.Entity;
+import javax.persistence.PrimaryKeyJoinColumn;
+
+/**
+ * @author Andrey Vlasov
+ * @author Steve Ebersole
+ */
+@Entity
+@PrimaryKeyJoinColumn(name = "super_id")
+public class Sub extends Super {
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java
new file mode 100644
index 0000000000..41f320e828
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/identity/joinedSubClass/Super.java
@@ -0,0 +1,48 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.test.idgen.identity.joinedSubClass;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+
+import static javax.persistence.GenerationType.IDENTITY;
+import static javax.persistence.InheritanceType.JOINED;
+
+/**
+ * @author Andrey Vlasov
+ * @author Steve Ebersole
+ */
+@Entity
+@Inheritance(strategy = JOINED)
+public class Super {
+ @Id
+ @GeneratedValue(strategy = IDENTITY)
+ private Long id;
+
+ @Column
+ private Long value;
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java
index f4d4d1cf24..8acd8a1ab5 100755
--- a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java
@@ -34,6 +34,8 @@ import org.hibernate.EmptyInterceptor;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.TransactionException;
+
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@@ -44,6 +46,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* @author Gavin King
@@ -136,6 +139,40 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase {
}
+ /**
+ * Test that setting a transaction timeout will cause an Exception to occur
+ * if the transaction timeout is exceeded.
+ */
+ @Test
+ public void testTimeout() throws Exception {
+ final int TIMEOUT = 2;
+ final int WAIT = TIMEOUT + 1;
+ Session s = openSession();
+ // Get the transaction and set the timeout BEFORE calling begin()
+ Transaction t = s.getTransaction();
+ t.setTimeout( TIMEOUT );
+ t.begin();
+ // Sleep for an amount of time that exceeds the transaction timeout
+ Thread.sleep( WAIT * 1000 );
+ try {
+ // Do something with the transaction and try to commit it
+ s.persist( new User( "john", "test" ) );
+ t.commit();
+ fail( "Transaction should have timed out" );
+ }
+ catch ( TransactionException e ) {
+ // Insure that the Exception is "transaction timeout expired"
+ String exceptionActual = e.toString();
+ String exceptionExpected = "org.hibernate.TransactionException: transaction timeout expired";
+ if ( !exceptionActual.contains( exceptionExpected ) ) {
+ String msg = String.format( "Transaction failed for the wrong reason. Expected [%s] but received [%s]",
+ exceptionExpected, exceptionActual );
+ fail( msg );
+
+ }
+ }
+ }
+
@Test
public void testComponentInterceptor() {
final int checkPerm = 500;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java
index 5f787044b8..df5624df10 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java
@@ -31,6 +31,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.batch.internal.BatchBuilderImpl;
import org.hibernate.engine.jdbc.batch.internal.BatchingBatch;
@@ -45,8 +46,7 @@ import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.jdbc.Expectation;
import org.hibernate.jdbc.Expectations;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.test.common.JournalingBatchObserver;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
@@ -67,7 +67,7 @@ public class BatchingTest extends BaseUnitTestCase implements BatchKey {
@Before
public void setUp() throws Exception {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() )
.buildServiceRegistry();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
index df44a13605..f3bcb7d636 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java
@@ -27,6 +27,7 @@ import java.io.Serializable;
import java.util.IdentityHashMap;
import javax.persistence.EntityNotFoundException;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.CascadingAction;
@@ -45,7 +46,6 @@ import org.hibernate.event.spi.PersistEventListener;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.proxy.EntityNotFoundDelegate;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
index ba72672c97..cbd636ce8d 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
@@ -36,8 +36,8 @@ import org.hibernate.event.spi.EventType;
import org.hibernate.event.spi.LoadEvent;
import org.hibernate.event.spi.LoadEventListener;
import org.hibernate.integrator.spi.Integrator;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java
index 59193b4dc6..c824bcec51 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java
@@ -84,7 +84,7 @@ import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.jdbc.AbstractReturningWork;
import org.hibernate.jdbc.AbstractWork;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.RequiresDialect;
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java
new file mode 100644
index 0000000000..ff95a7b2f6
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/EnumUserType.java
@@ -0,0 +1,116 @@
+package org.hibernate.test.mapping.usertypes;
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.usertype.UserType;
+
+public class EnumUserType implements UserType, ParameterizedType {
+
+ private Class clazz = null;
+
+ public static EnumUserType createInstance(Class clazz){
+ if (!clazz.isEnum())
+ throw new IllegalArgumentException("Parameter has to be an enum-class");
+ EnumUserType that=new EnumUserType();
+ Properties p=new Properties();
+ p.setProperty("enumClassName", clazz.getName());
+ that.setParameterValues(p);
+ return that;
+ }
+
+ public void setParameterValues(Properties params) {
+ String enumClassName = params.getProperty("enumClassName");
+ if (enumClassName == null) {
+ throw new MappingException("enumClassName parameter not specified");
+ }
+
+ try {
+ this.clazz = Class.forName(enumClassName);
+ } catch (ClassNotFoundException e) {
+ throw new MappingException("enumClass " + enumClassName + " not found", e);
+ }
+ if (!this.clazz.isEnum()){
+ throw new MappingException("enumClass "+enumClassName+" doesn't refer to an Enum");
+ }
+ }
+
+ private static final int[] SQL_TYPES = {Types.CHAR};
+ public int[] sqlTypes() {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass() {
+ return clazz;
+ }
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
+ throws HibernateException, SQLException {
+ String name = resultSet.getString(names[0]);
+ Object result = null;
+ if (!resultSet.wasNull()) {
+ result = Enum.valueOf(clazz, name.trim());
+ }
+ return result;
+ }
+
+ @Override
+ public Object nullSafeGet(ResultSet resultSet, String[] names,
+ SessionImplementor session, Object owner) throws HibernateException,
+ SQLException {
+ return nullSafeGet(resultSet, names, owner);
+ }
+
+public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index)
+ throws HibernateException, SQLException {
+ if (null == value) {
+ preparedStatement.setNull(index, Types.VARCHAR);
+ } else {
+ preparedStatement.setString(index, ((Enum)value).name());
+ }
+ }
+
+ @Override
+public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index,
+ SessionImplementor session) throws HibernateException, SQLException {
+ nullSafeSet(preparedStatement, value, index);
+}
+
+ public Object deepCopy(Object value) throws HibernateException{
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable)value;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+ public boolean equals(Object x, Object y) throws HibernateException {
+ if (x == y)
+ return true;
+ if (null == x || null == y)
+ return false;
+ return x.equals(y);
+ }
+}
+
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml
new file mode 100644
index 0000000000..df6ed68b30
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java
new file mode 100644
index 0000000000..79ed360bd5
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEntity.java
@@ -0,0 +1,19 @@
+package org.hibernate.test.mapping.usertypes;
+
+public class TestEntity {
+ private int id;
+ private TestEnum testEnum;
+
+ public void setId(int id) {
+ this.id = id;
+ }
+ public int getId() {
+ return id;
+ }
+ public void setTestEnum(TestEnum testEnum) {
+ this.testEnum = testEnum;
+ }
+ public TestEnum getTestEnum() {
+ return testEnum;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java
new file mode 100644
index 0000000000..8aab6b72ba
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnum.java
@@ -0,0 +1,6 @@
+package org.hibernate.test.mapping.usertypes;
+
+public enum TestEnum {
+ FOO,
+ BAR;
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml
new file mode 100644
index 0000000000..20acceaae2
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+ org.hibernate.test.mapping.usertypes.TestEnum
+
+
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java
new file mode 100644
index 0000000000..dcd4cbc133
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/usertypes/UserTypeMappingTest.java
@@ -0,0 +1,58 @@
+package org.hibernate.test.mapping.usertypes;
+
+
+import java.util.Properties;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.service.ServiceRegistry;
+import org.hibernate.testing.ServiceRegistryBuilder;
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.junit4.BaseUnitTestCase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test for read-order independent resolution of user-defined types
+ * Testcase for issue HHH-7300
+ * @author Stefan Schulze
+ */
+@TestForIssue(jiraKey = "HHH-7300")
+public class UserTypeMappingTest extends BaseUnitTestCase{
+
+private Configuration cfg;
+private ServiceRegistry serviceRegistry;
+
+ @Before
+ public void setup(){
+ cfg=new Configuration();
+ Properties p = new Properties();
+ p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" );
+ p.put( "hibernate.connection.driver_class", "org.h2.Driver" );
+ p.put( "hibernate.connection.url", "jdbc:h2:mem:" );
+ p.put( "hibernate.connection.username", "sa" );
+ p.put( "hibernate.connection.password", "" );
+ cfg.setProperties(p);
+ serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
+ }
+
+ @Test
+ public void testFirstTypeThenEntity(){
+ cfg.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml")
+ .addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml");
+ SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
+ Assert.assertNotNull(sessions);
+ }
+
+ @Test
+ public void testFirstEntityThenType(){
+ cfg.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml")
+ .addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml");
+
+ SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
+ Assert.assertNotNull(sessions);
+ }
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java
index f258c62f57..b84e8e4435 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/ConfigurationValidationTest.java
@@ -4,10 +4,10 @@ import org.junit.Test;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.MultiTenancyStrategy;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.testing.TestForIssue;
@@ -25,7 +25,7 @@ public class ConfigurationValidationTest extends BaseUnitTestCase {
cfg.getProperties().put( Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA );
cfg.setProperty( Environment.MULTI_TENANT_CONNECTION_PROVIDER, "class.not.present.in.classpath" );
cfg.buildMappings();
- ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder()
+ ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() ).buildServiceRegistry();
cfg.buildSessionFactory( serviceRegistry );
}
@@ -37,7 +37,7 @@ public class ConfigurationValidationTest extends BaseUnitTestCase {
cfg.getProperties().put( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.AFTER_STATEMENT.name() );
cfg.buildMappings();
- ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder()
+ ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() )
.addService(
MultiTenantConnectionProvider.class,
diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java
index 64d78abae8..8ca54675f3 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/TestingConnectionProvider.java
@@ -26,8 +26,8 @@ package org.hibernate.test.multitenancy;
import java.util.HashMap;
import java.util.Map;
-import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java
index d20f253416..5ddcfc1837 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java
@@ -38,11 +38,11 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.mapping.RootClass;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.testing.cache.CachingRegionFactory;
import org.hibernate.testing.env.ConnectionProviderBuilder;
@@ -66,7 +66,7 @@ public class SchemaBasedMultiTenancyTest extends BaseUnitTestCase {
AbstractMultiTenantConnectionProvider multiTenantConnectionProvider = buildMultiTenantConnectionProvider();
Configuration cfg = buildConfiguration();
- serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder()
+ serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder()
.applySettings( cfg.getProperties() )
.addService( MultiTenantConnectionProvider.class, multiTenantConnectionProvider )
.buildServiceRegistry();
diff --git a/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java b/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java
index 54cdd62da1..1371dd159c 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/naturalid/immutableentity/ImmutableEntityNaturalIdTest.java
@@ -159,6 +159,48 @@ public class ImmutableEntityNaturalIdTest extends BaseCoreFunctionalTestCase {
tx.rollback();
s.close();
}
+
+ @Test
+ @TestForIssue( jiraKey = "HHH-7371" )
+ public void testImmutableNaturalIdLifecycle2() {
+ Building b1 = new Building();
+ b1.setName( "Computer Science" );
+ b1.setAddress( "1210 W. Dayton St." );
+ b1.setCity( "Madison" );
+ b1.setState( "WI" );
+
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ s.persist( b1 );
+ tx.commit();
+ s.close();
+
+
+ s = openSession();
+ tx = s.beginTransaction();
+ NaturalIdLoadAccess naturalIdLoader = s.byNaturalId( Building.class );
+ naturalIdLoader.using( "address", "1210 W. Dayton St." ).using( "city", "Madison" ).using( "state", "WI" );
+ Building building = (Building) naturalIdLoader.getReference();
+ assertNotNull( building );
+
+ s.delete( building );
+ building = (Building) naturalIdLoader.load();
+ //org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.hibernate.test.naturalid.immutableentity.Building#1]
+// at org.hibernate.internal.SessionFactoryImpl$1$1.handleEntityNotFound(SessionFactoryImpl.java:247)
+// at org.hibernate.event.internal.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:282)
+// at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:248)
+// at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:148)
+// at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1079)
+// at org.hibernate.internal.SessionImpl.access$13(SessionImpl.java:1075)
+// at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2425)
+// at org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.load(SessionImpl.java:2586)
+// at org.hibernate.test.naturalid.immutableentity.ImmutableEntityNaturalIdTest.testImmutableNaturalIdLifecycle2(ImmutableEntityNaturalIdTest.java:188)
+
+ assertNull( building );
+
+ tx.commit();
+ s.close();
+ }
@Override
protected Class[] getAnnotatedClasses() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java
index 7650b2c5d0..18a4db1353 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkTest.java
@@ -30,13 +30,17 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.H2Dialect;
+
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
+@RequiresDialect(H2Dialect.class)
public class DoesNotWorkTest extends BaseCoreFunctionalTestCase {
@Override
protected Class>[] getAnnotatedClasses() {
diff --git a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java
index 33def68a71..5c3d7405c0 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWorkWithHbmTest.java
@@ -23,6 +23,9 @@
*/
package org.hibernate.test.propertyref;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.List;
import org.junit.Test;
@@ -30,16 +33,17 @@ import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
-import org.hibernate.testing.FailureExpectedWithNewMetamodel;
-import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+import org.hibernate.dialect.H2Dialect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.hibernate.testing.FailureExpectedWithNewMetamodel;
+import org.hibernate.testing.RequiresDialect;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
+@RequiresDialect(H2Dialect.class)
public class DoesNotWorkWithHbmTest extends BaseCoreFunctionalTestCase {
@Override
diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java
index 92e9c291e6..4fc2d0fcb2 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportSuppliedConnectionTest.java
@@ -37,19 +37,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
*/
public class SchemaExportSuppliedConnectionTest extends SchemaExportTest {
- private ServiceRegistry serviceRegistry;
-
- @Before
- public void setUp() {
- serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
- }
-
- @After
- public void tearDown() {
- ServiceRegistryBuilder.destroy( serviceRegistry );
- serviceRegistry = null;
- }
-
@Override
protected SchemaExport createSchemaExport(Configuration cfg) {
return new SchemaExport( serviceRegistry, cfg );
diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java
index f30de872f3..a0d55002fd 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/schemaupdate/SchemaExportTest.java
@@ -23,10 +23,15 @@
*/
package org.hibernate.test.schemaupdate;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
+import org.hibernate.service.ServiceRegistry;
+import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.tool.hbm2ddl.SchemaExport;
@@ -44,6 +49,22 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect()
.supportsIfExistsBeforeTableName();
}
+ protected ServiceRegistry serviceRegistry;
+
+ @Before
+ public void setUp() {
+ serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
+ Configuration cfg = new Configuration();
+ cfg.addResource( MAPPING );
+ SchemaExport schemaExport = createSchemaExport( cfg );
+ schemaExport.drop( true, true );
+ }
+
+ @After
+ public void tearDown() {
+ ServiceRegistryBuilder.destroy( serviceRegistry );
+ serviceRegistry = null;
+ }
@Test
public void testCreateAndDropOnlyType() {
@@ -52,12 +73,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
SchemaExport schemaExport = createSchemaExport( cfg );
// create w/o dropping first; (OK because tables don't exist yet
schemaExport.execute( false, true, false, true );
- if ( doesDialectSupportDropTableIfExist() ) {
+// if ( doesDialectSupportDropTableIfExist() ) {
assertEquals( 0, schemaExport.getExceptions().size() );
- }
- else {
- assertEquals( 2, schemaExport.getExceptions().size() );
- }
+// }
+// else {
+// assertEquals( 2, schemaExport.getExceptions().size() );
+// }
// create w/o dropping again; should be an exception for each table
// (2 total) because the tables exist already
// assertEquals( 0, schemaExport.getExceptions().size() );
@@ -96,7 +117,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
SchemaExport schemaExport = createSchemaExport( cfg );
// should drop before creating, but tables don't exist yet
schemaExport.create( true, true );
- assertEquals( 0, schemaExport.getExceptions().size() );
+ if ( doesDialectSupportDropTableIfExist() ) {
+ assertEquals( 0, schemaExport.getExceptions().size() );
+ }
+ else {
+ assertEquals( 2, schemaExport.getExceptions().size() );
+ }
// call create again; it should drop tables before re-creating
schemaExport.create( true, true );
assertEquals( 0, schemaExport.getExceptions().size() );
diff --git a/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java b/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java
index 64c7632e49..7609a5ffc8 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/service/ClassLoaderServiceImplTest.java
@@ -1,14 +1,13 @@
package org.hibernate.test.service;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.persistence.Entity;
-
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.junit.Assert;
import org.junit.Test;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
+import javax.persistence.Entity;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
/**
* @author Artem V. Navrotskiy
diff --git a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java
index 12b5a287b7..f92c6f060a 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java
@@ -23,31 +23,33 @@
*/
package org.hibernate.test.service;
-import java.util.Properties;
-
-import org.junit.Test;
-
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.H2Dialect;
-import org.hibernate.engine.jdbc.spi.JdbcServices;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.testing.env.ConnectionProviderBuilder;
-import org.hibernate.testing.junit4.BaseUnitTestCase;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.Properties;
+
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.spi.JdbcServices;
+import org.hibernate.testing.RequiresDialect;
+import org.hibernate.testing.RequiresDialect;
+import org.hibernate.testing.env.ConnectionProviderBuilder;
+import org.hibernate.testing.junit4.BaseUnitTestCase;
+import org.junit.Test;
+
/**
* @author Steve Ebersole
*/
+@RequiresDialect( H2Dialect.class )
public class ServiceBootstrappingTest extends BaseUnitTestCase {
@Test
public void testBasicBuild() {
- StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() )
.buildServiceRegistry();
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
@@ -64,7 +66,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
props.put( Environment.SHOW_SQL, "true" );
- StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( props )
.buildServiceRegistry();
@@ -79,7 +81,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
@Test
public void testBuildWithServiceOverride() {
- StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() )
.buildServiceRegistry();
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
@@ -90,7 +92,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
props.setProperty( Environment.DIALECT, H2Dialect.class.getName() );
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( props )
.addService( ConnectionProvider.class, new UserSuppliedConnectionProviderImpl() )
.buildServiceRegistry();
diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java
index fcd64f33b0..accc188c0a 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java
@@ -33,12 +33,12 @@ import org.junit.Before;
import org.junit.Test;
import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl;
@@ -58,7 +58,7 @@ public class TestExpectedUsage extends BaseUnitTestCase {
@Before
public void setUp() throws Exception {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( ConnectionProviderBuilder.getConnectionProviderProperties() )
.buildServiceRegistry();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java
index 397ef9546c..4230cba476 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java
@@ -34,15 +34,15 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl;
@@ -70,7 +70,7 @@ public class BasicDrivingTest extends BaseUnitTestCase {
configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
configValues.put( Environment.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName() );
TestingJtaBootstrap.prepare( configValues );
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( configValues )
.buildServiceRegistry();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java
index c983b85fd2..05fd185188 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java
@@ -23,44 +23,47 @@
*/
package org.hibernate.test.transaction.jta;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
+
import javax.transaction.TransactionManager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl;
+import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.junit4.BaseUnitTestCase;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Testing transaction facade handling when the transaction is being driven by something other than the facade.
*
* @author Steve Ebersole
*/
+@RequiresDialect(H2Dialect.class)
public class ManagedDrivingTest extends BaseUnitTestCase {
private StandardServiceRegistryImpl serviceRegistry;
@@ -71,7 +74,7 @@ public class ManagedDrivingTest extends BaseUnitTestCase {
TestingJtaBootstrap.prepare( configValues );
configValues.put( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( configValues )
.buildServiceRegistry();
}
diff --git a/hibernate-core/src/test/resources/org/hibernate/jmx/Entity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/jmx/Entity.hbm.xml
deleted file mode 100644
index a4502b40d7..0000000000
--- a/hibernate-core/src/test/resources/org/hibernate/jmx/Entity.hbm.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java
index db1edbc53f..fff05b346d 100644
--- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java
+++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AbstractEhcacheRegionFactory.java
@@ -48,15 +48,10 @@ import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
-import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.spi.InjectService;
-import org.hibernate.service.spi.ServiceRegistryAwareService;
-import org.hibernate.service.spi.ServiceRegistryImplementor;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* Abstract implementation of an Ehcache specific RegionFactory.
diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java
new file mode 100644
index 0000000000..9efe6fa462
--- /dev/null
+++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/AvailabilityAnnouncerImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache.ehcache;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.boot.registry.selector.Availability;
+import org.hibernate.boot.registry.selector.AvailabilityAnnouncer;
+import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl;
+import org.hibernate.cache.spi.RegionFactory;
+
+/**
+ * Makes the 2 contained region factory implementations available to the Hibernate
+ * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service.
+ *
+ * @author Steve Ebersole
+ */
+public class AvailabilityAnnouncerImpl implements AvailabilityAnnouncer {
+ @Override
+ @SuppressWarnings("unchecked")
+ public Iterable getAvailabilities() {
+ final List availabilities = new ArrayList();
+
+ availabilities.add(
+ new SimpleAvailabilityImpl(
+ RegionFactory.class,
+ EhCacheRegionFactory.class,
+ "ehcache",
+ EhCacheRegionFactory.class.getSimpleName(),
+ "org.hibernate.cache.EhCacheRegionFactory" // legacy impl class name
+ )
+ );
+
+ availabilities.add(
+ new SimpleAvailabilityImpl(
+ RegionFactory.class,
+ SingletonEhCacheRegionFactory.class,
+ "ehcache-singleton",
+ SingletonEhCacheRegionFactory.class.getSimpleName(),
+ "org.hibernate.cache.SingletonEhCacheRegionFactory" // legacy impl class name
+ )
+ );
+
+ return availabilities;
+ }
+}
diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java
index f8a78ba138..10a4c28caf 100644
--- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java
+++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/management/impl/ProviderMBeanRegistrationHelper.java
@@ -149,7 +149,7 @@ public class ProviderMBeanRegistrationHelper {
throw new RuntimeException( "Expected 'sessionFactoryMap' field on " + SessionFactoryRegistry.class.getName() );
}
instancesField.setAccessible( true );
- Map map = (Map) instancesField.get( null );
+ Map map = (Map) instancesField.get( SessionFactoryRegistry.INSTANCE );
if ( map == null ) {
return null;
}
diff --git a/hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer b/hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer
new file mode 100644
index 0000000000..4089ec9f31
--- /dev/null
+++ b/hibernate-ehcache/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer
@@ -0,0 +1 @@
+org.hibernate.cache.ehcache.AvailabilityAnnouncerImpl
\ No newline at end of file
diff --git a/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java b/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java
index e118a6c163..a8244b3ef1 100644
--- a/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java
+++ b/hibernate-ehcache/src/test/java/org/hibernate/test/cache/HibernateCacheTest.java
@@ -1,17 +1,15 @@
package org.hibernate.test.cache;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.hamcrest.CoreMatchers;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.hibernate.HibernateException;
import org.hibernate.Session;
-import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cache.ehcache.internal.strategy.ItemValueExtractor;
import org.hibernate.cache.spi.access.SoftLock;
@@ -25,49 +23,31 @@ import org.hibernate.test.domain.Item;
import org.hibernate.test.domain.Person;
import org.hibernate.test.domain.PhoneNumber;
import org.hibernate.test.domain.VersionedItem;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
+import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
+import org.junit.Test;
/**
* @author Chris Dennis
+ * @author Brett Meyer
*/
-public class HibernateCacheTest {
+public class HibernateCacheTest extends BaseCoreFunctionalTestCase {
- private static SessionFactory sessionFactory;
- private static Configuration config;
private static final String REGION_PREFIX = "hibernate.test.";
- public synchronized static SessionFactory getSessionFactory() {
- if ( sessionFactory == null ) {
- try {
- sessionFactory = config.buildSessionFactory();
- }
- catch ( HibernateException ex ) {
- System.err.println( "Initial SessionFactory creation failed." + ex );
- throw new ExceptionInInitializerError( ex );
- }
- }
- return sessionFactory;
- }
-
- @BeforeClass
- public static void setUp() {
+ @Override
+ protected void configure(Configuration config) {
System.setProperty( "derby.system.home", "target/derby" );
- config = new Configuration().configure( "/hibernate-config/hibernate.cfg.xml" );
- config.setProperty( "hibernate.hbm2ddl.auto", "create" );
- getSessionFactory().getStatistics().setStatisticsEnabled( true );
+ config.configure( "hibernate-config/hibernate.cfg.xml" );
}
-
- @AfterClass
- public static void tearDown() {
- getSessionFactory().close();
+
+ @Override
+ protected void afterSessionFactoryBuilt() {
+ sessionFactory().getStatistics().setStatisticsEnabled( true );
}
@Test
public void testQueryCacheInvalidation() throws Exception {
- Session s = getSessionFactory().openSession();
+ Session s = sessionFactory().openSession();
Transaction t = s.beginTransaction();
Item i = new Item();
i.setName( "widget" );
@@ -76,7 +56,7 @@ public class HibernateCacheTest {
t.commit();
s.close();
- SecondLevelCacheStatistics slcs = s.getSessionFactory()
+ SecondLevelCacheStatistics slcs = sessionFactory()
.getStatistics()
.getSecondLevelCacheStatistics( REGION_PREFIX + Item.class.getName() );
@@ -84,7 +64,7 @@ public class HibernateCacheTest {
assertThat( slcs.getElementCountInMemory(), equalTo( 1L ) );
assertThat( slcs.getEntries().size(), equalTo( 1 ) );
- s = getSessionFactory().openSession();
+ s = sessionFactory().openSession();
t = s.beginTransaction();
i = (Item) s.get( Item.class, i.getId() );
@@ -110,7 +90,7 @@ public class HibernateCacheTest {
assertThat( (String) map.get( "name" ), equalTo( "widget" ) );
// cleanup
- s = getSessionFactory().openSession();
+ s = sessionFactory().openSession();
t = s.beginTransaction();
s.delete( i );
t.commit();
@@ -119,8 +99,8 @@ public class HibernateCacheTest {
@Test
public void testEmptySecondLevelCacheEntry() throws Exception {
- getSessionFactory().evictEntity( Item.class.getName() );
- Statistics stats = getSessionFactory().getStatistics();
+ sessionFactory().evictEntity( Item.class.getName() );
+ Statistics stats = sessionFactory().getStatistics();
stats.clear();
SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( REGION_PREFIX + Item.class.getName() );
Map cacheEntries = statistics.getEntries();
@@ -129,7 +109,7 @@ public class HibernateCacheTest {
@Test
public void testStaleWritesLeaveCacheConsistent() {
- Session s = getSessionFactory().openSession();
+ Session s = sessionFactory().openSession();
Transaction txn = s.beginTransaction();
VersionedItem item = new VersionedItem();
item.setName( "steve" );
@@ -144,7 +124,7 @@ public class HibernateCacheTest {
item.setVersion( item.getVersion() - 1 );
try {
- s = getSessionFactory().openSession();
+ s = sessionFactory().openSession();
txn = s.beginTransaction();
s.update( item );
txn.commit();
@@ -172,7 +152,7 @@ public class HibernateCacheTest {
}
// check the version value in the cache...
- SecondLevelCacheStatistics slcs = getSessionFactory().getStatistics()
+ SecondLevelCacheStatistics slcs = sessionFactory().getStatistics()
.getSecondLevelCacheStatistics( REGION_PREFIX + VersionedItem.class.getName() );
assertThat( slcs, CoreMatchers.notNullValue() );
final Map entries = slcs.getEntries();
@@ -189,7 +169,7 @@ public class HibernateCacheTest {
// cleanup
- s = getSessionFactory().openSession();
+ s = sessionFactory().openSession();
txn = s.beginTransaction();
item = (VersionedItem) s.load( VersionedItem.class, item.getId() );
s.delete( item );
@@ -200,8 +180,8 @@ public class HibernateCacheTest {
@Test
public void testGeneralUsage() {
- EventManager mgr = new EventManager( getSessionFactory() );
- Statistics stats = getSessionFactory().getStatistics();
+ EventManager mgr = new EventManager( sessionFactory() );
+ Statistics stats = sessionFactory().getStatistics();
// create 3 persons Steve, Orion, Tim
Person stevePerson = new Person();
@@ -247,8 +227,6 @@ public class HibernateCacheTest {
mgr.listEmailsOfEvent( event.getId() );
}
- getSessionFactory().close();
-
QueryStatistics queryStats = stats.getQueryStatistics( "from Event" );
assertThat( "Cache Miss Count", queryStats.getCacheMissCount(), equalTo( 1L ) );
assertThat( "Cache Hit Count", queryStats.getCacheHitCount(), equalTo( 0L ) );
diff --git a/hibernate-entitymanager/hibernate-entitymanager.gradle b/hibernate-entitymanager/hibernate-entitymanager.gradle
index fb219fe5a3..617ce7a0d3 100644
--- a/hibernate-entitymanager/hibernate-entitymanager.gradle
+++ b/hibernate-entitymanager/hibernate-entitymanager.gradle
@@ -24,7 +24,6 @@ dependencies {
////////////////////////////////////////////////////////////////////////////////////////////////////////
// JPA model-gen set up
////////////////////////////////////////////////////////////////////////////////////////////////////////
-aptDumpDir = file( "${buildDir}/tmp/apt" )
sourceSets.test {
originalJavaSrcDirs = java.srcDirs
@@ -32,6 +31,7 @@ sourceSets.test {
java.srcDir generatedJpaMetamodelSrcDir
}
task generateTestJpaMetamodelClasses(type: Compile) {
+ ext.aptDumpDir = file( "${buildDir}/tmp/apt/jpamodelgen" )
classpath = compileTestJava.classpath + configurations.hibernateJpaModelGenTool
source = sourceSets.test.originalJavaSrcDirs
destinationDir = aptDumpDir
@@ -46,6 +46,9 @@ task generateTestJpaMetamodelClasses(type: Compile) {
doFirst {
sourceSets.test.generatedJpaMetamodelSrcDir.mkdirs()
}
+ doLast {
+ aptDumpDir.delete()
+ }
}
// for the time being eat the annoying output from running the annotation processors
generateTestJpaMetamodelClasses.logging.captureStandardError(LogLevel.INFO)
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java
index 548790aeee..2123fd1846 100644
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java
@@ -64,6 +64,11 @@ import org.hibernate.MappingException;
import org.hibernate.MappingNotFoundException;
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.StandardServiceRegistryBuilder;
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.CacheRegionDefinition;
import org.hibernate.boot.spi.JaccDefinition;
import org.hibernate.cfg.Configuration;
@@ -74,15 +79,17 @@ 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.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.jpa.AvailableSettings;
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
import org.hibernate.jpa.boot.spi.IntegratorProvider;
import org.hibernate.jpa.boot.spi.JpaUnifiedSettingsBuilder;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
+import org.hibernate.jpa.event.spi.JpaIntegrator;
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
-import org.hibernate.jpa.event.spi.JpaIntegrator;
import org.hibernate.jpa.internal.util.LogHelper;
import org.hibernate.jpa.internal.util.PersistenceUnitTransactionTypeHelper;
import org.hibernate.jpa.packaging.internal.NativeScanner;
@@ -93,15 +100,10 @@ import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.internal.JACCConfiguration;
-import org.hibernate.service.BootstrapServiceRegistry;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import static org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping;
-import static org.hibernate.jpa.boot.spi.JpaBootstrapServiceRegistryBuilder.buildBootstrapServiceRegistry;
/**
* @author Steve Ebersole
@@ -131,7 +133,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
private final PersistenceUnitDescriptor persistenceUnit;
private final SettingsImpl settings = new SettingsImpl();
- private final ServiceRegistryBuilder serviceRegistryBuilder;
+ private final StandardServiceRegistryBuilder serviceRegistryBuilder;
private final Map,?> configurationValues;
private final List jaccDefinitions = new ArrayList();
@@ -164,9 +166,9 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// First we build the boot-strap service registry, which mainly handles class loader interactions
- final BootstrapServiceRegistry bootstrapServiceRegistry = buildBootstrapServiceRegistry( persistenceUnit, integrationSettings );
+ final BootstrapServiceRegistry bootstrapServiceRegistry = buildBootstrapServiceRegistry( integrationSettings );
// And the main service registry. This is needed to start adding configuration values, etc
- this.serviceRegistryBuilder = new ServiceRegistryBuilder( bootstrapServiceRegistry );
+ this.serviceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry );
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Next we build a merged map of all the configuration values
@@ -195,6 +197,38 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
}
+ /**
+ * Builds the {@link BootstrapServiceRegistry} used to eventually build the {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}; mainly
+ * used here during instantiation to define class-loading behavior.
+ *
+ * @param integrationSettings Any integration settings passed by the EE container or SE application
+ *
+ * @return The built BootstrapServiceRegistry
+ */
+ private BootstrapServiceRegistry buildBootstrapServiceRegistry(Map integrationSettings) {
+ final BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder();
+ bootstrapServiceRegistryBuilder.with( new JpaIntegrator() );
+
+ final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get( INTEGRATOR_PROVIDER );
+ if ( integratorProvider != null ) {
+ integrationSettings.remove( INTEGRATOR_PROVIDER );
+ for ( Integrator integrator : integratorProvider.getIntegrators() ) {
+ bootstrapServiceRegistryBuilder.with( integrator );
+ }
+ }
+
+ ClassLoader classLoader = (ClassLoader) integrationSettings.get( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
+ if ( classLoader != null ) {
+ integrationSettings.remove( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
+ }
+ else {
+ classLoader = persistenceUnit.getClassLoader();
+ }
+ bootstrapServiceRegistryBuilder.withApplicationClassLoader( classLoader );
+
+ return bootstrapServiceRegistryBuilder.build();
+ }
+
@SuppressWarnings("unchecked")
private Map mergePropertySources(
PersistenceUnitDescriptor persistenceUnit,
@@ -789,7 +823,9 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
SessionFactoryImplementor sessionFactory;
try {
- sessionFactory = (SessionFactoryImplementor) hibernateConfiguration.buildSessionFactory( serviceRegistry );
+ sessionFactory = (SessionFactoryImplementor) hibernateConfiguration.buildSessionFactory(
+ serviceRegistry
+ );
}
catch (MappingException e) {
throw persistenceException( "Unable to build Hibernate SessionFactory", e );
@@ -801,7 +837,13 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
sessionFactory.addObserver( new ServiceRegistryCloser() );
// NOTE : passing cfg is temporary until
- return new EntityManagerFactoryImpl( persistenceUnit.getName(), sessionFactory, settings, configurationValues, hibernateConfiguration );
+ return new EntityManagerFactoryImpl(
+ persistenceUnit.getName(),
+ sessionFactory,
+ settings,
+ configurationValues,
+ hibernateConfiguration
+ );
}
}
);
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java
index 437ac2283e..bcb70600d7 100644
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java
@@ -58,9 +58,9 @@ import org.hibernate.jpa.internal.EntityManagerMessageLogger;
import org.hibernate.jpa.packaging.internal.JarVisitorFactory;
import org.hibernate.jpa.internal.util.ConfigurationHelper;
import org.hibernate.internal.util.StringHelper;
+import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.spi.source.XsdException;
-import org.hibernate.service.classloading.internal.ClassLoaderServiceImpl;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
/**
* Used by Hibernate to parse {@code persistence.xml} files in SE environments.
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/spi/JpaUnifiedSettingsBuilder.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/spi/JpaUnifiedSettingsBuilder.java
index 5413e1b689..c362742d99 100644
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/spi/JpaUnifiedSettingsBuilder.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/spi/JpaUnifiedSettingsBuilder.java
@@ -29,13 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.spi.CacheRegionDefinition;
import org.hibernate.boot.spi.JaccDefinition;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.jpa.AvailableSettings;
-import org.hibernate.service.BootstrapServiceRegistry;
import org.hibernate.service.ConfigLoader;
import static org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping;
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java
index 2e55804b10..5598e8ea05 100644
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/BeanManagerListenerFactory.java
@@ -42,6 +42,10 @@ public class BeanManagerListenerFactory implements ListenerFactory {
private final BeanManager beanManager;
private final Map listeners = new ConcurrentHashMap();
+ public static BeanManagerListenerFactory fromBeanManagerReference(Object beanManagerReference) {
+ return new BeanManagerListenerFactory( ( BeanManager ) beanManagerReference );
+ }
+
public BeanManagerListenerFactory(BeanManager beanManager) {
this.beanManager = beanManager;
}
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java
index b9e2a5904d..ebe31e5305 100644
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/internal/jpa/CallbackProcessorImpl.java
@@ -32,11 +32,11 @@ import org.jboss.logging.Logger;
import org.hibernate.MappingException;
import org.hibernate.jpa.event.spi.jpa.Callback;
import org.hibernate.jpa.event.spi.jpa.ListenerFactory;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.source.JpaCallbackSource;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
/**
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java
index b7754ad78b..df602b509c 100644
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/event/spi/JpaIntegrator.java
@@ -23,7 +23,8 @@
*/
package org.hibernate.jpa.event.spi;
-import javax.enterprise.inject.spi.BeanManager;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
@@ -54,7 +55,6 @@ import org.hibernate.jpa.event.internal.core.JpaPostLoadEventListener;
import org.hibernate.jpa.event.internal.core.JpaPostUpdateEventListener;
import org.hibernate.jpa.event.internal.core.JpaSaveEventListener;
import org.hibernate.jpa.event.internal.core.JpaSaveOrUpdateEventListener;
-import org.hibernate.jpa.event.internal.jpa.BeanManagerListenerFactory;
import org.hibernate.jpa.event.internal.jpa.CallbackProcessor;
import org.hibernate.jpa.event.internal.jpa.CallbackProcessorImpl;
import org.hibernate.jpa.event.internal.jpa.CallbackRegistryConsumer;
@@ -70,7 +70,7 @@ import org.hibernate.secure.internal.JACCPreInsertEventListener;
import org.hibernate.secure.internal.JACCPreLoadEventListener;
import org.hibernate.secure.internal.JACCPreUpdateEventListener;
import org.hibernate.secure.internal.JACCSecurityListener;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
@@ -187,10 +187,10 @@ public class JpaIntegrator implements Integrator {
// handle JPA "entity listener classes"...
this.callbackRegistry = new CallbackRegistryImpl();
- final BeanManager beanManager = (BeanManager) configuration.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER );
- this.jpaListenerFactory = beanManager == null
+ final Object beanManagerRef = configuration.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER );
+ this.jpaListenerFactory = beanManagerRef == null
? new StandardListenerFactory()
- : new BeanManagerListenerFactory( beanManager );
+ : buildBeanManagerListenerFactory( beanManagerRef );
this.callbackProcessor = new LegacyCallbackProcessor( jpaListenerFactory, configuration.getReflectionManager() );
Iterator classes = configuration.getClassMappings();
@@ -213,11 +213,34 @@ public class JpaIntegrator implements Integrator {
}
}
- /**
- * {@inheritDoc}
- *
- * @see org.hibernate.integrator.spi.Integrator#integrate(org.hibernate.metamodel.spi.MetadataImplementor, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.service.spi.SessionFactoryServiceRegistry)
- */
+ private ListenerFactory buildBeanManagerListenerFactory(Object beanManagerRef) {
+ try {
+ // specifically using our classloader here...
+ final Class beanManagerListenerFactoryClass = getClass().getClassLoader()
+ .loadClass( "org.hibernate.jpa.event.internal.jpa.BeanManagerListenerFactory" );
+ final Method beanManagerListenerFactoryBuilderMethod = beanManagerListenerFactoryClass.getMethod(
+ "fromBeanManagerReference",
+ Object.class
+ );
+
+ try {
+ return (ListenerFactory) beanManagerListenerFactoryBuilderMethod.invoke( null, beanManagerRef );
+ }
+ catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ }
+ }
+ catch (ReflectiveOperationException e) {
+ throw new HibernateException( "Could not access BeanManagerListenerFactory class to handle CDI extensions", e );
+ }
+ catch (RuntimeException e) {
+ throw e;
+ }
+ catch (Throwable e) {
+ throw new HibernateException( "Problem calling BeanManagerListenerFactory class to handle CDI extensions", e );
+ }
+ }
+
@Override
public void integrate(
MetadataImplementor metadata,
@@ -293,10 +316,10 @@ public class JpaIntegrator implements Integrator {
// handle JPA "entity listener classes"...
this.callbackRegistry = new CallbackRegistryImpl();
- final BeanManager beanManager = (BeanManager) sessionFactory.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER );
- this.jpaListenerFactory = beanManager == null
+ final Object beanManagerRef = sessionFactory.getProperties().get( AvailableSettings.CDI_BEAN_MANAGER );
+ this.jpaListenerFactory = beanManagerRef == null
? new StandardListenerFactory()
- : new BeanManagerListenerFactory( beanManager );
+ : buildBeanManagerListenerFactory( beanManagerRef );
this.callbackProcessor = new CallbackProcessorImpl( jpaListenerFactory, metadata, serviceRegistry );
for ( EntityBinding binding : metadata.getEntityBindings() ) {
diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java
index a81080cb9b..74d2444f5e 100755
--- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java
+++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java
@@ -125,7 +125,7 @@ import org.hibernate.jpa.internal.util.CacheModeHelper;
import org.hibernate.jpa.internal.util.ConfigurationHelper;
import org.hibernate.jpa.internal.util.LockModeTypeHelper;
import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.transform.BasicTransformerAdapter;
import org.hibernate.type.Type;
diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java
index 27df78bada..4fca26b4e3 100644
--- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java
+++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java
@@ -46,7 +46,7 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java
new file mode 100644
index 0000000000..48b4cb9ddb
--- /dev/null
+++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTest.java
@@ -0,0 +1,138 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.jpa.test.cdi;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import org.hibernate.bytecode.spi.ByteCodeHelper;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.hibernate.testing.junit4.BaseUnitTestCase;
+import org.hibernate.testing.junit4.ClassLoadingIsolater;
+
+import static org.junit.Assert.fail;
+
+/**
+ * Test JPA bootstrapping when CDI is not available for classloading.
+ *
+ * @author Steve Ebersole
+ */
+public class NoCdiAvailableTest extends BaseUnitTestCase {
+ public static final String[] EXCLUDED_PACKAGES = new String[] {
+ "javax.enterprise.inject.",
+ "javax.enterprise.context."
+ };
+
+ private static class CdiClassLoadException extends RuntimeException {
+ private CdiClassLoadException(String message) {
+ super( message );
+ }
+ }
+
+ @Rule public ClassLoadingIsolater isolater = new ClassLoadingIsolater(
+ new ClassLoadingIsolater.IsolatedClassLoaderProvider() {
+
+ @Override
+ public ClassLoader buildIsolatedClassLoader() {
+ return new ClassLoader(NoCdiAvailableTest.class.getClassLoader()) {
+ @Override
+ public Class> loadClass(String name) throws ClassNotFoundException {
+ for ( String excludedPackage : EXCLUDED_PACKAGES ) {
+ if ( name.startsWith( excludedPackage ) ) {
+ throw new CdiClassLoadException( "CDI classes [" + name + "] excluded from load" );
+ }
+ }
+
+ Class c = findLoadedClass( name );
+ if ( c != null ) {
+ return c;
+ }
+
+ final String resourceName = name.replace( '.', '/' ) + ".class";
+ final URL resource = getResource( resourceName );
+ if ( resource == null ) {
+ throw new ClassNotFoundException( name + " not found" );
+ }
+ if ( !"file".equals( resource.getProtocol() ) ) {
+ return getParent().loadClass( name );
+ }
+
+ InputStream is = this.getResourceAsStream( name.replace( '.', '/' ) + ".class" );
+ if ( is == null ) {
+ throw new ClassNotFoundException( name + " not found" );
+ }
+
+ try {
+ byte[] bytecode = ByteCodeHelper.readByteCode( is );
+ return defineClass( name, bytecode, 0, bytecode.length );
+ }
+ catch( Throwable t ) {
+ throw new ClassNotFoundException( "Error reading class file for " + name, t );
+ }
+ }
+ };
+ }
+
+ @Override
+ public void releaseIsolatedClassLoader(ClassLoader isolatedClassLoader) {
+ // nothing to do
+ }
+ }
+ );
+
+ @Test
+ public void testJpaBootstrapWithoutCdiAvailable() throws Exception {
+ Class delegateClass = Thread.currentThread().getContextClassLoader().loadClass(
+ "org.hibernate.jpa.test.cdi.NoCdiAvailableTestDelegate"
+ );
+ Method mainMethod = delegateClass.getMethod( "passingNoBeanManager" );
+ mainMethod.invoke( null );
+ }
+
+ @Test
+ public void testJpaBootstrapWithoutCdiAvailablePassingCdi() throws Throwable {
+ Class delegateClass = Thread.currentThread().getContextClassLoader().loadClass(
+ "org.hibernate.jpa.test.cdi.NoCdiAvailableTestDelegate"
+ );
+ Method mainMethod = delegateClass.getMethod( "passingBeanManager" );
+ try {
+ mainMethod.invoke( null );
+ fail( "Expecting failure from missing CDI classes" );
+ }
+ catch (InvocationTargetException e) {
+ try {
+ throw e.getTargetException();
+ }
+ catch (CdiClassLoadException expected) {
+ }
+// catch (ClassCastException expectedAlt) {
+// }
+ }
+ }
+}
diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java
new file mode 100644
index 0000000000..36fc59a044
--- /dev/null
+++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/cdi/NoCdiAvailableTestDelegate.java
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.jpa.test.cdi;
+
+import java.util.Collections;
+
+import org.hibernate.jpa.AvailableSettings;
+import org.hibernate.jpa.HibernatePersistenceProvider;
+import org.hibernate.jpa.test.PersistenceUnitInfoAdapter;
+
+/**
+ * @author Steve Ebersole
+ */
+public class NoCdiAvailableTestDelegate {
+ public static void passingNoBeanManager() {
+ new HibernatePersistenceProvider().createContainerEntityManagerFactory(
+ new PersistenceUnitInfoAdapter(),
+ Collections.emptyMap()
+ );
+ }
+
+ public static void passingBeanManager() {
+ new HibernatePersistenceProvider().createContainerEntityManagerFactory(
+ new PersistenceUnitInfoAdapter(),
+ Collections.singletonMap( AvailableSettings.CDI_BEAN_MANAGER, new Object() )
+ );
+ }
+}
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java
index 9ccd515913..1316da28d3 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/AuditConfiguration.java
@@ -40,7 +40,7 @@ import org.hibernate.envers.strategy.ValidityAuditStrategy;
import org.hibernate.envers.synchronization.AuditProcessManager;
import org.hibernate.envers.tools.reflection.ReflectionTools;
import org.hibernate.property.Getter;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
/**
* @author Adam Warski (adam at warski dot org)
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java
index 9de2e5a9c6..a6b37dc602 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java
@@ -26,6 +26,7 @@ package org.hibernate.envers.event;
import org.jboss.logging.Logger;
import org.hibernate.cfg.Configuration;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.event.service.spi.EventListenerRegistry;
@@ -33,9 +34,8 @@ import org.hibernate.event.spi.EventType;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.metamodel.spi.MetadataImplementor;
-import org.hibernate.service.classloading.spi.ClassLoaderService;
-import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.config.spi.StandardConverters;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
@@ -73,11 +73,6 @@ public class EnversIntegrator implements Integrator {
// nothing to do afaik
}
- /**
- * {@inheritDoc}
- *
- * @see org.hibernate.integrator.spi.Integrator#integrate(org.hibernate.metamodel.spi.MetadataImplementor, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.service.spi.SessionFactoryServiceRegistry)
- */
@Override
public void integrate( MetadataImplementor metadata,
SessionFactoryImplementor sessionFactory,
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java
index 659396ee5b..d14819b3e4 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversPostUpdateEventListenerImpl.java
@@ -78,12 +78,14 @@ public class EnversPostUpdateEventListenerImpl extends BaseEnversEventListener i
private Object[] postUpdateDBState(PostUpdateEvent event) {
Object[] newDbState = event.getState().clone();
- EntityPersister entityPersister = event.getPersister();
- for ( int i = 0; i < entityPersister.getPropertyNames().length; ++i ) {
- if ( !entityPersister.getPropertyUpdateability()[i] ) {
- // Assuming that PostUpdateEvent#getOldState() returns database state of the record before modification.
- // Otherwise, we would have to execute SQL query to be sure of @Column(updatable = false) column value.
- newDbState[i] = event.getOldState()[i];
+ if ( event.getOldState() != null ) {
+ EntityPersister entityPersister = event.getPersister();
+ for ( int i = 0; i < entityPersister.getPropertyNames().length; ++i ) {
+ if ( !entityPersister.getPropertyUpdateability()[i] ) {
+ // Assuming that PostUpdateEvent#getOldState() returns database state of the record before modification.
+ // Otherwise, we would have to execute SQL query to be sure of @Column(updatable = false) column value.
+ newDbState[i] = event.getOldState()[i];
+ }
}
}
return newDbState;
diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java b/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java
index 5c6f09f271..5f388b9075 100644
--- a/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java
+++ b/hibernate-envers/src/main/java/org/hibernate/envers/tools/Tools.java
@@ -82,7 +82,7 @@ public class Tools {
public static Object getTargetFromProxy(SessionFactoryImplementor sessionFactoryImplementor, HibernateProxy proxy) {
- if (!proxy.getHibernateLazyInitializer().isUninitialized()) {
+ if (!proxy.getHibernateLazyInitializer().isUninitialized() || activeProxySession(proxy)) {
return proxy.getHibernateLazyInitializer().getImplementation();
}
@@ -102,6 +102,11 @@ public class Tools {
}
}
+ private static boolean activeProxySession(HibernateProxy proxy) {
+ Session session = (Session) proxy.getHibernateLazyInitializer().getSession();
+ return session != null && session.isOpen() && session.isConnected();
+ }
+
/**
* @param clazz Class wrapped with a proxy or not.
* @param Class type.
diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java
index 3eea5518fa..8e76f72c47 100644
--- a/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java
+++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java
@@ -47,7 +47,7 @@ import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
import org.hibernate.jpa.boot.spi.Bootstrap;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.junit.After;
diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java
new file mode 100644
index 0000000000..10e7c65af7
--- /dev/null
+++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/onetomany/detached/DetachedTest.java
@@ -0,0 +1,80 @@
+package org.hibernate.envers.test.integration.onetomany.detached;
+
+import java.util.Arrays;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+import org.hibernate.Session;
+import org.hibernate.envers.test.BaseEnversFunctionalTestCase;
+import org.hibernate.envers.test.Priority;
+import org.hibernate.envers.test.entities.StrTestEntity;
+import org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity;
+import org.hibernate.testing.TestForIssue;
+
+/**
+ * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
+ */
+public class DetachedTest extends BaseEnversFunctionalTestCase {
+ private Integer parentId = null;
+ private Integer childId = null;
+
+ @Override
+ protected Class>[] getAnnotatedClasses() {
+ return new Class[] { ListRefCollEntity.class, StrTestEntity.class };
+ }
+
+ @Test
+ @Priority(10)
+ @TestForIssue(jiraKey = "HHH-7543")
+ public void testUpdatingDetachedEntityWithRelation() {
+ Session session = getSession();
+
+ // Revision 1
+ session.getTransaction().begin();
+ ListRefCollEntity parent = new ListRefCollEntity( 1, "initial data" );
+ StrTestEntity child = new StrTestEntity( "data" );
+ session.save( child );
+ parent.setCollection( Arrays.asList( child ) );
+ session.save( parent );
+ session.getTransaction().commit();
+
+ session.close();
+ session = getSession();
+
+ // Revision 2 - updating detached entity
+ session.getTransaction().begin();
+ parent.setData( "modified data" );
+ session.update( parent );
+ session.getTransaction().commit();
+
+ session.close();
+
+ parentId = parent.getId();
+ childId = child.getId();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ Assert.assertEquals( Arrays.asList( 1, 2 ), getAuditReader().getRevisions( ListRefCollEntity.class, parentId ) );
+ Assert.assertEquals( Arrays.asList( 1 ), getAuditReader().getRevisions( StrTestEntity.class, childId ) );
+ }
+
+ @Test
+ public void testHistoryOfParent() {
+ ListRefCollEntity parent = new ListRefCollEntity( parentId, "initial data" );
+ parent.setCollection( Arrays.asList( new StrTestEntity( "data", childId ) ) );
+
+ ListRefCollEntity ver1 = getAuditReader().find( ListRefCollEntity.class, parentId, 1 );
+
+ Assert.assertEquals( parent, ver1 );
+ Assert.assertEquals( parent.getCollection(), ver1.getCollection() );
+
+ parent.setData( "modified data" );
+
+ ListRefCollEntity ver2 = getAuditReader().find( ListRefCollEntity.class, parentId, 2 );
+
+ Assert.assertEquals( parent, ver2 );
+ Assert.assertEquals( parent.getCollection(), ver2.getCollection() );
+ }
+}
\ No newline at end of file
diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java
index a4c6e56b39..da3fdd326a 100644
--- a/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java
+++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java
@@ -28,6 +28,7 @@ import java.util.Arrays;
import java.util.Properties;
import javax.persistence.EntityManager;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter;
import org.hibernate.envers.test.AbstractEnversTest;
import org.junit.Before;
@@ -41,8 +42,7 @@ import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory;
import org.hibernate.envers.event.EnversIntegrator;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.AfterClassOnce;
import org.hibernate.testing.BeforeClassOnce;
diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java
new file mode 100644
index 0000000000..fc6ad8eccd
--- /dev/null
+++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/AvailabilityAnnouncerImpl.java
@@ -0,0 +1,65 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.cache.infinispan;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.boot.registry.selector.Availability;
+import org.hibernate.boot.registry.selector.AvailabilityAnnouncer;
+import org.hibernate.boot.registry.selector.SimpleAvailabilityImpl;
+import org.hibernate.cache.spi.RegionFactory;
+
+/**
+ * Makes the 2 contained region factory implementations available to the Hibernate
+ * {@link org.hibernate.boot.registry.selector.spi.StrategySelector} service.
+ *
+ * @author Steve Ebersole
+ */
+public class AvailabilityAnnouncerImpl implements AvailabilityAnnouncer {
+ @Override
+ public Iterable getAvailabilities() {
+ final List availabilities = new ArrayList();
+
+ availabilities.add(
+ new SimpleAvailabilityImpl(
+ RegionFactory.class,
+ InfinispanRegionFactory.class,
+ "infinispan",
+ InfinispanRegionFactory.class.getSimpleName()
+ )
+ );
+
+ availabilities.add(
+ new SimpleAvailabilityImpl(
+ RegionFactory.class,
+ JndiInfinispanRegionFactory.class,
+ "infinispan-jndi",
+ JndiInfinispanRegionFactory.class.getSimpleName()
+ )
+ );
+
+ return availabilities;
+ }
+}
diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java
index c3345e92c6..fb09623f13 100644
--- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java
+++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/tm/HibernateTransactionManagerLookup.java
@@ -25,8 +25,8 @@ import java.util.Properties;
import javax.transaction.TransactionManager;
import org.hibernate.cfg.Settings;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
/**
* HibernateTransactionManagerLookup.
diff --git a/hibernate-infinispan/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer b/hibernate-infinispan/src/main/resources/META-INF/services/org.hibernate.boot.registry.selector.AvailabilityAnnouncer
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java
index 6ee5e505d4..16e007b671 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractEntityCollectionRegionTestCase.java
@@ -88,7 +88,7 @@ public abstract class AbstractEntityCollectionRegionTestCase extends AbstractReg
// // Make it non-transactional
// cfg.getProperties().remove( AvailableSettings.JTA_PLATFORM );
// regionFactory = CacheTestUtil.startRegionFactory(
-// ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
+// StandardServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
// cfg,
// getCacheTestSupport()
// );
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java
index babe5f8e48..88d2530530 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java
@@ -29,13 +29,14 @@ import org.infinispan.transaction.tm.BatchModeTransactionManager;
import org.jboss.logging.Logger;
import org.junit.Test;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cache.spi.GeneralDataRegion;
import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.Region;
import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.junit.Assert.assertEquals;
@@ -77,7 +78,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
private void evictOrRemoveTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
@@ -93,7 +94,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
cfg = createConfiguration();
regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
@@ -147,7 +148,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
private void evictOrRemoveAllTest(String configName) throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
@@ -165,7 +166,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
cfg = createConfiguration();
regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
index 8a1010aa34..89f04fb7da 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/InfinispanRegionFactoryTestCase.java
@@ -41,8 +41,9 @@ import org.hibernate.cache.internal.RegionFactoryInitiator;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform;
+
import org.hibernate.testing.ServiceRegistryBuilder;
import static org.junit.Assert.assertEquals;
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java
index e71a96a97c..2d5097ee26 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
@@ -34,10 +35,8 @@ import org.hibernate.cache.infinispan.util.FlagAdapter;
import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.Configuration;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
import static org.hibernate.cache.infinispan.util.CacheHelper.withinTx;
@@ -114,7 +113,7 @@ public class NodeEnvironment {
}
public void prepare() throws Exception {
- serviceRegistry = (StandardServiceRegistryImpl) new ServiceRegistryBuilder()
+ serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( configuration.getProperties() )
.buildServiceRegistry();
sessionFactory = (SessionFactoryImplementor)configuration.buildSessionFactory( serviceRegistry );
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java
index 2c92b77d6d..7ef3ca0ebc 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/ConcurrentWriteTest.java
@@ -47,8 +47,8 @@ import org.hibernate.Session;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cfg.Configuration;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeConnectionProviderImpl;
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaPlatformImpl;
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java
index e2b9d14e25..590a7d8fad 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/SingleNodeTestCase.java
@@ -37,8 +37,8 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionFactory;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.test.cache.infinispan.tm.JtaPlatformImpl;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
index 2a92e251a2..ffc9da4ac4 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/bulk/BulkOperationsTestCase.java
@@ -38,8 +38,8 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionFactory;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.test.cache.infinispan.functional.Contact;
import org.hibernate.test.cache.infinispan.functional.Customer;
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java
index 53afc9aa93..78318ae252 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeConnectionProviderImpl.java
@@ -29,7 +29,7 @@ import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.testing.env.ConnectionProviderBuilder;
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java
index 80fe23837e..ac8f980aad 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeJtaPlatformImpl.java
@@ -33,7 +33,7 @@ import javax.transaction.UserTransaction;
import org.hibernate.HibernateException;
import org.hibernate.TransactionException;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.Configurable;
/**
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java
index 4735d0693a..d75ef850d6 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTestCase.java
@@ -33,7 +33,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/**
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java
deleted file mode 100644
index 6a8ed79294..0000000000
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/functional/cluster/DualNodeTransactionManagerLookup.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc. and/or it's affiliates.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.cache.infinispan.functional.cluster;
-
-import java.util.Properties;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.hibernate.HibernateException;
-import org.hibernate.transaction.TransactionManagerLookup;
-
-/**
- * SimpleJtaTransactionManagerLookupImpl subclass that finds a different DualNodeTransactionManager
- * based on the value of property {@link DualNodeTestUtil#NODE_ID_PROP}.
- *
- * @author Brian Stansberry
- */
-public class DualNodeTransactionManagerLookup implements TransactionManagerLookup {
-
- public TransactionManager getTransactionManager(Properties props) throws HibernateException {
- String nodeId = props.getProperty(DualNodeTestCase.NODE_ID_PROP);
- if (nodeId == null)
- throw new HibernateException(DualNodeTestCase.NODE_ID_PROP + " not configured");
- return DualNodeJtaTransactionManagerImpl.getInstance(nodeId);
- }
-
- public String getUserTransactionName() {
- throw new UnsupportedOperationException("jndi currently not implemented for these tests");
- }
-
- public Object getTransactionIdentifier(Transaction transaction) {
- return transaction;
- }
-}
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java
index 7d52f2df21..3991bd708c 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java
@@ -36,6 +36,7 @@ import org.infinispan.transaction.tm.BatchModeTransactionManager;
import org.infinispan.util.concurrent.IsolationLevel;
import org.jboss.logging.Logger;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
@@ -46,7 +47,7 @@ import org.hibernate.cache.spi.GeneralDataRegion;
import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.Region;
import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
@@ -112,7 +113,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
private void putDoesNotBlockGetTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
@@ -212,7 +213,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
private void getDoesNotBlockPutTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java
index 41d7d00a15..977fcc031e 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java
@@ -38,6 +38,7 @@ import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
import org.infinispan.notifications.cachelistener.event.Event;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.impl.ClassLoaderAwareCache;
import org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl;
@@ -48,7 +49,7 @@ import org.hibernate.cache.spi.CacheDataDescription;
import org.hibernate.cache.spi.Region;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
+
import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
import org.hibernate.test.cache.infinispan.functional.classloader.Account;
import org.hibernate.test.cache.infinispan.functional.classloader.AccountHolder;
@@ -81,7 +82,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
public void testClearTimestampsRegionInIsolated() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg,
getCacheTestSupport()
);
@@ -90,7 +91,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
Configuration cfg2 = createConfiguration();
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
- new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
+ new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
cfg2,
getCacheTestSupport()
);
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java
index 4deab3b463..d0258ba3d4 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JBossStandaloneJtaExampleTest.java
@@ -23,12 +23,8 @@
*/
package org.hibernate.test.cache.infinispan.tm;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
import java.util.Iterator;
import java.util.Properties;
-import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
@@ -36,10 +32,8 @@ import javax.naming.NameNotFoundException;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.transaction.Status;
-import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.enhydra.jdbc.standard.StandardXADataSource;
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -59,10 +53,11 @@ import org.hibernate.cfg.Environment;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JBossStandAloneJtaPlatform;
import org.hibernate.stat.Statistics;
import org.hibernate.test.cache.infinispan.functional.Item;
import org.hibernate.testing.ServiceRegistryBuilder;
+import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -90,10 +85,9 @@ public class JBossStandaloneJtaExampleTest {
jndiServer = startJndiServer();
ctx = createJndiContext();
// Inject configuration to initialise transaction manager from config classloader
- lookup.init(new org.infinispan.config.Configuration());
+ lookup.init( new org.infinispan.config.Configuration() );
bindTransactionManager();
bindUserTransaction();
- bindDataSource();
}
@After
@@ -180,55 +174,20 @@ public class JBossStandaloneJtaExampleTest {
}
- public static class ExtendedXADataSource extends StandardXADataSource { // XAPOOL
- @Override
- public Connection getConnection() throws SQLException {
-
- if (getTransactionManager() == null) { // although already set before, it results null again after retrieving the datasource by jndi
- TransactionManager tm; // this is because the TransactionManager information is not serialized.
- try {
- tm = lookup.getTransactionManager();
- } catch (Exception e) {
- throw new SQLException(e);
- }
- setTransactionManager(tm); // resets the TransactionManager on the datasource retrieved by jndi,
- // this makes the datasource JTA-aware
- }
-
- // According to Enhydra documentation, here we must return the connection of our XAConnection
- // see http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/xapool/xapool/examples/xapooldatasource/DatabaseHelper.java?sortby=rev
- return super.getXAConnection().getConnection();
- }
-
- @Override
- public T unwrap(Class iface) throws SQLException {
- return null; // JDK6 stuff
- }
-
- @Override
- public boolean isWrapperFor(Class> iface) throws SQLException {
- return false; // JDK6 stuff
- }
-
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- return null;
- }
- }
-
private Main startJndiServer() throws Exception {
// Create an in-memory jndi
NamingServer namingServer = new NamingServer();
NamingContext.setLocal(namingServer);
Main namingMain = new Main();
namingMain.setInstallGlobalService(true);
- namingMain.setPort(-1);
+ namingMain.setPort( -1 );
namingMain.start();
return namingMain;
}
private Context createJndiContext() throws Exception {
Properties props = new Properties();
- props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ props.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
return new InitialContext(props);
}
@@ -240,14 +199,7 @@ public class JBossStandaloneJtaExampleTest {
private void bindUserTransaction() throws Exception {
// also the UserTransaction must be registered on jndi: org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory#getUserTransaction() requires this
- bind("UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx);
- }
-
- private void bindDataSource() throws Exception {
- ExtendedXADataSource xads = new ExtendedXADataSource();
- xads.setDriverName("org.h2.Driver");
- xads.setUrl("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE");
- ctx.bind("java:/MyDatasource", xads);
+ bind( "UserTransaction", lookup.getUserTransaction(), lookup.getUserTransaction().getClass(), ctx );
}
/**
@@ -289,12 +241,11 @@ public class JBossStandaloneJtaExampleTest {
private SessionFactory buildSessionFactory() {
// Extra options located in src/test/resources/hibernate.properties
Configuration cfg = new Configuration();
- cfg.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
- cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
- cfg.setProperty(Environment.DATASOURCE, "java:/MyDatasource");
+ cfg.setProperty( Environment.DIALECT, "HSQL" );
+ cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
+ cfg.setProperty( Environment.CONNECTION_PROVIDER, JtaAwareConnectionProviderImpl.class.getName() );
cfg.setProperty(Environment.JNDI_CLASS, "org.jnp.interfaces.NamingContextFactory");
- cfg.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, "org.hibernate.transaction.JBossTransactionManagerLookup");
- cfg.setProperty(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JTATransactionFactory");
+ cfg.setProperty(Environment.TRANSACTION_STRATEGY, "jta");
cfg.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
cfg.setProperty(Environment.RELEASE_CONNECTIONS, "auto");
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java
index 95db052882..20e0674c09 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/JtaPlatformImpl.java
@@ -31,7 +31,7 @@ import javax.transaction.UserTransaction;
import org.hibernate.TransactionException;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* @author Steve Ebersole
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java
index e0ec86a820..2be132d95c 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java
@@ -27,7 +27,7 @@ import java.util.Properties;
import org.hibernate.HibernateException;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.testing.env.ConnectionProviderBuilder;
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java
index 6d6f75d17d..a53aced180 100644
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java
+++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeJtaPlatform.java
@@ -34,7 +34,7 @@ import org.infinispan.transaction.tm.BatchModeTransactionManager;
import org.hibernate.HibernateException;
import org.hibernate.TransactionException;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
/**
* @author Steve Ebersole
diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java
deleted file mode 100755
index bf2f29625a..0000000000
--- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/util/BatchModeTransactionManagerLookup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc. and/or it's affiliates.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.test.cache.infinispan.util;
-
-import java.util.Properties;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.infinispan.transaction.tm.BatchModeTransactionManager;
-
-import org.hibernate.HibernateException;
-import org.hibernate.transaction.TransactionManagerLookup;
-
-/**
- * Uses the JBoss Cache BatchModeTransactionManager. Should not be used in
- * any tests that simulate usage of database connections.
- *
- * @author Brian Stansberry
- */
-public class BatchModeTransactionManagerLookup
- implements TransactionManagerLookup {
-
- public TransactionManager getTransactionManager(Properties props) throws HibernateException {
- try {
- return BatchModeTransactionManager.getInstance();
- }
- catch (Exception e) {
- throw new HibernateException("Failed getting BatchModeTransactionManager", e);
- }
- }
-
- public String getUserTransactionName() {
- throw new UnsupportedOperationException();
- }
-
- public Object getTransactionIdentifier(Transaction transaction) {
- return transaction;
- }
-
-}
diff --git a/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java b/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java
index 116116b5fc..a4ac220c2c 100644
--- a/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java
+++ b/hibernate-proxool/src/main/java/org/hibernate/service/jdbc/connections/internal/ProxoolConnectionProvider.java
@@ -40,7 +40,7 @@ import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.UnknownUnwrapTypeException;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
/**
* A connection provider that uses a Proxool connection pool. Hibernate will use this by
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java
index 902d14ce91..efab4e2d63 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java
@@ -25,9 +25,10 @@ package org.hibernate.testing;
import java.util.Map;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Environment;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
/**
* @author Steve Ebersole
@@ -38,7 +39,7 @@ public class ServiceRegistryBuilder {
}
public static StandardServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) {
- return (StandardServiceRegistryImpl) new org.hibernate.service.ServiceRegistryBuilder()
+ return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder()
.applySettings( serviceRegistryConfig )
.buildServiceRegistry();
}
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java b/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java
index 2a71f83f38..b6453dc475 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java
@@ -34,15 +34,9 @@ import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.EntityRegion;
import org.hibernate.cache.spi.NaturalIdRegion;
import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.Settings;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.config.spi.StandardConverters;
-import org.hibernate.service.spi.InjectService;
/**
* @author Strong Liu
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java
index 443a13a346..e7aef85b82 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java
@@ -28,7 +28,7 @@ import java.util.Properties;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
-import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
/**
* Defines the JDBC connection information (currently H2) used by Hibernate for unit (not functional!) tests
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java
index 74ec5f1e1e..c429a64c39 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java
@@ -37,10 +37,9 @@ import java.util.Map;
import java.util.Properties;
import org.hibernate.cfg.Environment;
-import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
-import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
-import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator;
+import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.Stoppable;
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java
index 5cac046eb0..fc607fd48e 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaPlatformImpl.java
@@ -32,10 +32,10 @@ import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.internal.arjuna.objectstore.VolatileStore;
import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
-import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform;
-import org.hibernate.service.jta.platform.internal.JtaSynchronizationStrategy;
-import org.hibernate.service.jta.platform.internal.SynchronizationRegistryAccess;
-import org.hibernate.service.jta.platform.internal.SynchronizationRegistryBasedSynchronizationStrategy;
+import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.internal.JtaSynchronizationStrategy;
+import org.hibernate.engine.transaction.jta.platform.internal.SynchronizationRegistryAccess;
+import org.hibernate.engine.transaction.jta.platform.internal.SynchronizationRegistryBasedSynchronizationStrategy;
/**
* A test-specific implementation of the JtaPlatform contract for testing JTA-based functionality.
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseAnnotationBindingTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseAnnotationBindingTestCase.java
index 3e073fe6ab..7c190bef17 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseAnnotationBindingTestCase.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseAnnotationBindingTestCase.java
@@ -33,10 +33,10 @@ import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.spi.binding.EntityBinding;
-import org.hibernate.service.ServiceRegistryBuilder;
/**
* @author Hardy Ferentschik
@@ -106,7 +106,7 @@ public abstract class BaseAnnotationBindingTestCase extends BaseUnitTestCase {
private void createBindings() {
try {
- sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
+ sources = new MetadataSources( new StandardServiceRegistryBuilder().buildServiceRegistry() );
Resources resourcesAnnotation = description.getAnnotation( Resources.class );
if ( resourcesAnnotation != null ) {
sources.getMetadataBuilder().with( resourcesAnnotation.cacheMode() );
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java
index 01c8a5eeba..96e6169b64 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java
@@ -40,6 +40,7 @@ import org.junit.Before;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.Session;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
@@ -58,17 +59,16 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.metamodel.MetadataSources;
+import org.hibernate.boot.registry.BootstrapServiceRegistry;
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.AbstractPluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.EntityBinding;
-import org.hibernate.service.BootstrapServiceRegistry;
-import org.hibernate.service.BootstrapServiceRegistryBuilder;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.config.spi.ConfigurationService;
-import org.hibernate.service.internal.StandardServiceRegistryImpl;
+import org.hibernate.engine.config.spi.ConfigurationService;
+import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.testing.AfterClassOnce;
import org.hibernate.testing.BeforeClassOnce;
import org.hibernate.testing.OnExpectedFailure;
@@ -197,7 +197,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
protected Configuration constructConfiguration() {
Configuration configuration = new Configuration()
- .setProperty(Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
+ .setProperty( Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
configuration.setProperty( AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
if ( createSchema() ) {
configuration.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
@@ -399,7 +399,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
ConfigurationHelper.resolvePlaceHolders( properties );
final BootstrapServiceRegistry bootstrapServiceRegistry = generateBootstrapRegistry( properties );
- ServiceRegistryBuilder registryBuilder = new ServiceRegistryBuilder( bootstrapServiceRegistry )
+ StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry )
.applySettings( properties );
prepareBasicRegistryBuilder( registryBuilder );
return (StandardServiceRegistryImpl) registryBuilder.buildServiceRegistry();
@@ -414,7 +414,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
}
- protected void prepareBasicRegistryBuilder(ServiceRegistryBuilder serviceRegistryBuilder) {
+ protected void prepareBasicRegistryBuilder(StandardServiceRegistryBuilder serviceRegistryBuilder) {
}
protected void afterSessionFactoryBuilt() {
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java
index f80b801194..7866276c2d 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/ExtraAssertions.java
@@ -23,8 +23,16 @@
*/
package org.hibernate.testing.junit4;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Assert;
+import static org.junit.Assert.fail;
+
/**
* @author Steve Ebersole
*/
@@ -51,4 +59,44 @@ public class ExtraAssertions {
}
return (T) value;
}
+
+ public static void assertJdbcTypeCode(int expected, int actual) {
+ if ( expected != actual ) {
+ final String message = String.format(
+ "JDBC type codes did not match...\n" +
+ "Expected: %s (%s)\n" +
+ "Actual : %s (%s)",
+ jdbcTypeCodeMap().get( expected ),
+ expected,
+ jdbcTypeCodeMap().get( actual ),
+ actual
+ );
+ fail( message );
+ }
+ }
+
+ private static Map jdbcTypeCodeMap;
+
+ private static synchronized Map jdbcTypeCodeMap() {
+ if ( jdbcTypeCodeMap == null ) {
+ jdbcTypeCodeMap = generateJdbcTypeCache();
+ }
+ return jdbcTypeCodeMap;
+ }
+
+ private static Map generateJdbcTypeCache() {
+ final Field[] fields = Types.class.getFields();
+ Map cache = new HashMap( (int)( fields.length * .75 ) + 1 );
+ for ( int i = 0; i < fields.length; i++ ) {
+ final Field field = fields[i];
+ if ( Modifier.isStatic( field.getModifiers() ) ) {
+ try {
+ cache.put( field.get( null ), field.getName() );
+ }
+ catch ( Throwable ignore ) {
+ }
+ }
+ }
+ return cache;
+ }
}