From ab97bf0bf02ced3a0db34d3a189a0008bcd53009 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 31 Aug 2010 19:07:03 +0000 Subject: [PATCH] HHH-5517 - Switch uuid generation in SessionFactory to org.hibernate.id.UUIDGenerator instead git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20296 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../java/org/hibernate/id/UUIDGenerator.java | 7 ++++ .../hibernate/impl/SessionFactoryImpl.java | 6 ++-- .../org/hibernate/jmx/SessionFactoryStub.java | 32 +++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/org/hibernate/id/UUIDGenerator.java b/core/src/main/java/org/hibernate/id/UUIDGenerator.java index 5da35a3c3d..50d33dea70 100644 --- a/core/src/main/java/org/hibernate/id/UUIDGenerator.java +++ b/core/src/main/java/org/hibernate/id/UUIDGenerator.java @@ -65,6 +65,13 @@ public class UUIDGenerator implements IdentifierGenerator, Configurable { private UUIDGenerationStrategy strategy; private UUIDTypeDescriptor.ValueTransformer valueTransformer; + public static UUIDGenerator buildSessionFactoryUniqueIdentifierGenerator() { + final UUIDGenerator generator = new UUIDGenerator(); + generator.strategy = StandardRandomStrategy.INSTANCE; + generator.valueTransformer = UUIDTypeDescriptor.ToStringTransformer.INSTANCE; + return generator; + } + public void configure(Type type, Properties params, Dialect d) throws MappingException { // check first for the strategy instance strategy = (UUIDGenerationStrategy) params.get( UUID_GEN_STRATEGY ); diff --git a/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java b/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java index 55d2b10769..fbda191f57 100644 --- a/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java +++ b/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java @@ -95,7 +95,7 @@ import org.hibernate.engine.query.sql.NativeSQLQuerySpecification; import org.hibernate.event.EventListeners; import org.hibernate.exception.SQLExceptionConverter; import org.hibernate.id.IdentifierGenerator; -import org.hibernate.id.UUIDHexGenerator; +import org.hibernate.id.UUIDGenerator; import org.hibernate.id.factory.IdentifierGeneratorFactory; import org.hibernate.jdbc.BatcherFactory; import org.hibernate.mapping.Collection; @@ -128,7 +128,7 @@ import org.hibernate.util.ReflectHelper; /** * Concrete implementation of the SessionFactory interface. Has the following - * responsibilites + * responsibilities *