Hibernate SVN: r19491 - core/branches/Branch_3_5.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-05-12 17:12:13 -0400 (Wed, 12 May 2010)
New Revision: 19491
Modified:
core/branches/Branch_3_5/changelog.txt
Log:
update for 3.5.2
Modified: core/branches/Branch_3_5/changelog.txt
===================================================================
--- core/branches/Branch_3_5/changelog.txt 2010-05-12 21:10:24 UTC (rev 19490)
+++ core/branches/Branch_3_5/changelog.txt 2010-05-12 21:12:13 UTC (rev 19491)
@@ -6,6 +6,53 @@
more about each case.
+Changes in version 3.5.2 (2010.05.12)
+-------------------------------------------
+http://opensource.atlassian.com/projects/hibernate/browse/HHH/fixforversion/11040
+
+** Bug
+ * [HHH-3096] - COUNT DISTINCT operator with idenfication variable w/ composite primary key produces bad sql
+ * [HHH-3377] - Update H2Dialect to use DECIMAL SQL type instead of NUMERIC
+ * [HHH-3478] - StandardQueryCache.get() does not handle EntityNotFoundException for natural key lookups
+ * [HHH-4290] - Projection of composite key causes invalid SQL
+ * [HHH-4773] - @CollectionId does not force the id column to not-null
+ * [HHH-4952] - jDocBook injections no longer working on core reference manual
+ * [HHH-4957] - Criteria Projections.countDistinct() function broken
+ * [HHH-4966] - Entity Manager bug with ParameterExpressionImpl
+ * [HHH-4991] - ManyToMany table not joined due to max_fetch_depth parameter, results to SQL exceptions
+ * [HHH-5006] - hibernate.globally_quoted_identifiers=true and Annotations tests
+ * [HHH-5032] - Setting LockModeType.OPTIMISTIC_FORCE_INCREMENT defaults to only OPTIMISTIC
+ * [HHH-5042] - TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range
+ * [HHH-5063] - Projections that have aliases same as the property name result in invalid sql
+ * [HHH-5069] - Fix annotation documentation wrt setup
+ * [HHH-5125] - The annotations @Entity and @MappedSuperclass used in one class produce a nullpointerexception
+ * [HHH-5131] - SchemaExport drop fails if constraint names change
+ * [HHH-5135] - "Ambiguous column" exception thrown with columns having the same name as a function registered with the dialect (e.g. to_date, floor)
+ * [HHH-5140] - quoted column doesn't be quoted in sub-query
+ * [HHH-5173] - hql - average returns double but looses the decimal part
+ * [HHH-5178] - Unit tests in org.hibernate.test.immutable fail on mssql and sybase due to keyword used for table and column name
+ * [HHH-5191] - CollectionMetadataGenerator fails to obtain mappedBy attribute when is defined on superclasses
+ * [HHH-5207] - Unexpected exception occurs during refresh of a transient immutable business object.
+ * [HHH-5208] - Oracle 11g R2 RAC - Test SequenceIdentityTest fails because first value of sequence is "2"
+ * [HHH-5210] - Query Cache effective only after closing the session that created the cache
+ * [HHH-5211] - no need to create a schema first when run this test org.hibernate.test.sql.hand.custom.db2.DB2CustomSQLTest
+
+** Improvement
+ * [HHH-5144] - Dont restrict on jdk5 in hibernate core development
+ * [HHH-5217] - Minimize double sequence value reads in PooledOptimizer
+ * [HHH-5218] - Provide a new "pooled value" based optimizer which interprets the database value as the low boundary instead of upper boundary
+
+** Patch
+ * [HHH-1574] - AbstractEntityPersister.getNaturalIdentifierSnapshot doesn't work with many-to-one ids (Alex Burgel)
+ * [HHH-5064] - OrderBy string getting dumped to console on session factory creation (Shawn Clowater)
+ * [HHH-5078] - JPA criteria query numeric expressions produce wrong result (due to wrong bracketing)
+
+** Task
+ * [HHH-5145] - Update pom to use the new distributationManagement information
+ * [HHH-5186] - update db profiles id and jdbc properties' name to use dballocator
+ * [HHH-5196] - Deprecate Type methods on org.hibernate.Hibernate
+
+
Changes in version 3.5.1 (2010.04.14)
-------------------------------------------
http://opensource.atlassian.com/projects/hibernate/browse/HHH/fixforversi...
14 years
Hibernate SVN: r19490 - core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302/core/src/main/java/org/hibernate/util.
by hibernate-commits@lists.jboss.org
Author: smendenh(a)redhat.com
Date: 2010-05-12 17:10:24 -0400 (Wed, 12 May 2010)
New Revision: 19490
Modified:
core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302/core/src/main/java/org/hibernate/util/SerializationHelper.java
Log:
HHH-4786
Modified: core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302/core/src/main/java/org/hibernate/util/SerializationHelper.java
===================================================================
--- core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302/core/src/main/java/org/hibernate/util/SerializationHelper.java 2010-05-12 20:51:40 UTC (rev 19489)
+++ core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302/core/src/main/java/org/hibernate/util/SerializationHelper.java 2010-05-12 21:10:24 UTC (rev 19490)
@@ -36,6 +36,7 @@
import org.hibernate.type.SerializationException;
import org.hibernate.Hibernate;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,146 +61,186 @@
* @author Gary Gregory
* @since 1.0
* @version $Id: SerializationHelper.java 9180 2006-01-30 23:51:27Z steveebersole $
+ * @since 1.0
*/
public final class SerializationHelper {
- private static final Logger log = LoggerFactory.getLogger(SerializationHelper.class);
+ private static final Logger log = LoggerFactory.getLogger( SerializationHelper.class );
- private SerializationHelper() {}
+ private SerializationHelper() {
+ }
- // Clone
- //-----------------------------------------------------------------------
- /**
- * <p>Deep clone an <code>Object</code> using serialization.</p>
- *
- * <p>This is many times slower than writing clone methods by hand
- * on all objects in your object graph. However, for complex object
- * graphs, or for those that don't support deep cloning this can
- * be a simple alternative implementation. Of course all the objects
- * must be <code>Serializable</code>.</p>
- *
- * @param object the <code>Serializable</code> object to clone
- * @return the cloned object
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static Object clone(Serializable object) throws SerializationException {
- log.trace("Starting clone through serialization");
+ // Clone
+ //-----------------------------------------------------------------------
+
+ /**
+ * <p>Deep clone an <code>Object</code> using serialization.</p>
+ *
+ * <p>This is many times slower than writing clone methods by hand
+ * on all objects in your object graph. However, for complex object
+ * graphs, or for those that don't support deep cloning this can
+ * be a simple alternative implementation. Of course all the objects
+ * must be <code>Serializable</code>.</p>
+ *
+ * @param object the <code>Serializable</code> object to clone
+ *
+ * @return the cloned object
+ *
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static Object clone(Serializable object) throws SerializationException {
+ log.trace( "Starting clone through serialization" );
if ( object == null ) {
return null;
}
- return deserialize( serialize( object ), object.getClass().getClassLoader() );
- }
+ return deserialize( serialize( object ), object.getClass().getClassLoader() );
+ }
- // Serialize
- //-----------------------------------------------------------------------
- /**
- * <p>Serializes an <code>Object</code> to the specified stream.</p>
- *
- * <p>The stream will be closed once the object is written.
- * This avoids the need for a finally clause, and maybe also exception
- * handling, in the application code.</p>
- *
- * <p>The stream passed in is not buffered internally within this method.
- * This is the responsibility of your application if desired.</p>
- *
- * @param obj the object to serialize to bytes, may be null
- * @param outputStream the stream to write to, must not be null
- * @throws IllegalArgumentException if <code>outputStream</code> is <code>null</code>
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static void serialize(Serializable obj, OutputStream outputStream) throws SerializationException {
- if (outputStream == null) {
- throw new IllegalArgumentException("The OutputStream must not be null");
- }
+ // Serialize
+ //-----------------------------------------------------------------------
- if ( log.isTraceEnabled() ) {
- if ( Hibernate.isInitialized( obj ) ) {
- log.trace( "Starting serialization of object [" + obj + "]" );
- }
- else {
- log.trace( "Starting serialization of [uninitialized proxy]" );
- }
- }
+ /**
+ * <p>Serializes an <code>Object</code> to the specified stream.</p>
+ *
+ * <p>The stream will be closed once the object is written.
+ * This avoids the need for a finally clause, and maybe also exception
+ * handling, in the application code.</p>
+ *
+ * <p>The stream passed in is not buffered internally within this method.
+ * This is the responsibility of your application if desired.</p>
+ *
+ * @param obj the object to serialize to bytes, may be null
+ * @param outputStream the stream to write to, must not be null
+ *
+ * @throws IllegalArgumentException if <code>outputStream</code> is <code>null</code>
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static void serialize(Serializable obj, OutputStream outputStream) throws SerializationException {
+ if ( outputStream == null ) {
+ throw new IllegalArgumentException( "The OutputStream must not be null" );
+ }
- ObjectOutputStream out = null;
- try {
- // stream closed in the finally
- out = new ObjectOutputStream(outputStream);
- out.writeObject(obj);
+ if ( log.isTraceEnabled() ) {
+ if ( Hibernate.isInitialized( obj ) ) {
+ log.trace( "Starting serialization of object [" + obj + "]" );
+ }
+ else {
+ log.trace( "Starting serialization of [uninitialized proxy]" );
+ }
+ }
- }
- catch (IOException ex) {
- throw new SerializationException("could not serialize", ex);
- }
- finally {
- try {
- if (out != null) out.close();
- }
- catch (IOException ignored) {}
- }
- }
+ ObjectOutputStream out = null;
+ try {
+ // stream closed in the finally
+ out = new ObjectOutputStream( outputStream );
+ out.writeObject( obj );
- /**
- * <p>Serializes an <code>Object</code> to a byte array for
- * storage/serialization.</p>
- *
- * @param obj the object to serialize to bytes
- * @return a byte[] with the converted Serializable
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static byte[] serialize(Serializable obj) throws SerializationException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- serialize(obj, baos);
- return baos.toByteArray();
- }
+ }
+ catch ( IOException ex ) {
+ throw new SerializationException( "could not serialize", ex );
+ }
+ finally {
+ try {
+ if ( out != null ) {
+ out.close();
+ }
+ }
+ catch ( IOException ignored ) {
+ }
+ }
+ }
- // Deserialize
- //-----------------------------------------------------------------------
- /**
- * Deserializes an object from the specified stream using the Thread Context
- * ClassLoader (TCCL). If there is no TCCL set, the classloader of the calling
- * class is used.
- * <p/>
- * Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)}
- *
- * @param inputStream the serialized object input stream, must not be null
- * @return the deserialized object
- * @throws IllegalArgumentException if <code>inputStream</code> is <code>null</code>
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static Object deserialize(InputStream inputStream) throws SerializationException {
- return deserialize( inputStream, Thread.currentThread().getContextClassLoader() );
- }
+ /**
+ * <p>Serializes an <code>Object</code> to a byte array for
+ * storage/serialization.</p>
+ *
+ * @param obj the object to serialize to bytes
+ *
+ * @return a byte[] with the converted Serializable
+ *
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static byte[] serialize(Serializable obj) throws SerializationException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream( 512 );
+ serialize( obj, byteArrayOutputStream );
+ return byteArrayOutputStream.toByteArray();
+ }
- /**
- * Deserializes an object from the specified stream using the Thread Context
+ // Deserialize
+ //-----------------------------------------------------------------------
+
+ /**
+ * Deserializes an object from the specified stream using the Thread Context
+ * ClassLoader (TCCL).
+ * <p/>
+ * Delegates to {@link #doDeserialize}
+ *
+ * @param inputStream the serialized object input stream, must not be null
+ *
+ * @return the deserialized object
+ *
+ * @throws IllegalArgumentException if <code>inputStream</code> is <code>null</code>
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static Object deserialize(InputStream inputStream) throws SerializationException {
+ return doDeserialize( inputStream, defaultClassLoader(), hibernateClassLoader(), null );
+ }
+
+ /**
+ * Returns the Thread Context ClassLoader (TCCL).
+ *
+ * @return The current TCCL
+ */
+ public static ClassLoader defaultClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ public static ClassLoader hibernateClassLoader() {
+ return SerializationHelper.class.getClassLoader();
+ }
+
+ /**
+ * Deserializes an object from the specified stream using the Thread Context
* ClassLoader (TCCL). If there is no TCCL set, the classloader of the calling
* class is used.
- * <p/>
- * The stream will be closed once the object is read. This avoids the need
+ * <p/>
+ * The stream will be closed once the object is read. This avoids the need
* for a finally clause, and maybe also exception handling, in the application
* code.
- * <p/>
- * The stream passed in is not buffered internally within this method. This is
+ * <p/>
+ * The stream passed in is not buffered internally within this method. This is
* the responsibility of the caller, if desired.
- *
- * @param inputStream the serialized object input stream, must not be null
+ *
+ * @param inputStream the serialized object input stream, must not be null
* @param loader The classloader to use
*
- * @return the deserialized object
+ * @return the deserialized object
*
- * @throws IllegalArgumentException if <code>inputStream</code> is <code>null</code>
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static Object deserialize(InputStream inputStream, ClassLoader loader) throws SerializationException {
- if (inputStream == null) {
- throw new IllegalArgumentException( "The InputStream must not be null" );
- }
+ * @throws IllegalArgumentException if <code>inputStream</code> is <code>null</code>
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static Object deserialize(InputStream inputStream, ClassLoader loader) throws SerializationException {
+ return doDeserialize( inputStream, loader, defaultClassLoader(), hibernateClassLoader() );
+ }
+ public static Object doDeserialize(
+ InputStream inputStream,
+ ClassLoader loader,
+ ClassLoader fallbackLoader1,
+ ClassLoader fallbackLoader2) throws SerializationException {
+ if ( inputStream == null ) {
+ throw new IllegalArgumentException( "The InputStream must not be null" );
+ }
+
log.trace( "Starting deserialization of object" );
try {
- CustomObjectInputStream in = new CustomObjectInputStream( inputStream, loader );
+ CustomObjectInputStream in = new CustomObjectInputStream(
+ inputStream,
+ loader,
+ fallbackLoader1,
+ fallbackLoader2
+ );
try {
return in.readObject();
}
@@ -213,7 +254,7 @@
try {
in.close();
}
- catch (IOException ignore) {
+ catch ( IOException ignore ) {
// ignore
}
}
@@ -223,70 +264,118 @@
}
}
- /**
- * Deserializes an Object from an array of bytes.
+ /**
+ * Deserializes an object from an array of bytes using the Thread Context
+ * ClassLoader (TCCL). If there is no TCCL set, the classloader of the calling
+ * class is used.
* <p/>
* Delegates to {@link #deserialize(byte[], ClassLoader)}
- *
- * @param objectData the serialized object, must not be null
- * @return the deserialized object
- * @throws IllegalArgumentException if <code>objectData</code> is <code>null</code>
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static Object deserialize(byte[] objectData) throws SerializationException {
- return deserialize( objectData, Thread.currentThread().getContextClassLoader() );
- }
+ *
+ * @param objectData the serialized object, must not be null
+ *
+ * @return the deserialized object
+ *
+ * @throws IllegalArgumentException if <code>objectData</code> is <code>null</code>
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static Object deserialize(byte[] objectData) throws SerializationException {
+ return doDeserialize( wrap( objectData ), defaultClassLoader(), hibernateClassLoader(), null );
+ }
- /**
- * Deserializes an Object from an array of bytes.
+ private static InputStream wrap(byte[] objectData) {
+ if ( objectData == null ) {
+ throw new IllegalArgumentException( "The byte[] must not be null" );
+ }
+ return new ByteArrayInputStream( objectData );
+ }
+
+ /**
+ * Deserializes an object from an array of bytes.
* <p/>
* Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} using a
- * {@link ByteArrayInputStream} to wrap the array.
- *
- * @param objectData the serialized object, must not be null
+ * {@link ByteArrayInputStream} to wrap the array.
+ *
+ * @param objectData the serialized object, must not be null
* @param loader The classloader to use
*
- * @return the deserialized object
+ * @return the deserialized object
*
- * @throws IllegalArgumentException if <code>objectData</code> is <code>null</code>
- * @throws SerializationException (runtime) if the serialization fails
- */
- public static Object deserialize(byte[] objectData, ClassLoader loader) throws SerializationException {
- if ( objectData == null ) {
- throw new IllegalArgumentException( "The byte[] must not be null" );
- }
- ByteArrayInputStream bais = new ByteArrayInputStream( objectData );
- return deserialize( bais, loader );
- }
+ * @throws IllegalArgumentException if <code>objectData</code> is <code>null</code>
+ * @throws SerializationException (runtime) if the serialization fails
+ */
+ public static Object deserialize(byte[] objectData, ClassLoader loader) throws SerializationException {
+ return doDeserialize( wrap( objectData ), loader, defaultClassLoader(), hibernateClassLoader() );
+ }
/**
- * Custom ObjectInputStream implementation to more appropriately handle classloading
- * within app servers (mainly jboss - hence this class inspired by jboss's class of
- * the same purpose).
+ * By default, to resolve the classes being deserialized JDK serialization uses the
+ * classes loader which loaded the class which initiated the deserialization call. Here
+ * that would be hibernate classes. However, there are cases where that is not the correct
+ * class loader to use; mainly here we are worried about deserializing user classes in
+ * environments (app servers, etc) where Hibernate is on a parent classes loader. To
+ * facilitate for that we allow passing in the class loader we should use.
*/
private static final class CustomObjectInputStream extends ObjectInputStream {
- private final ClassLoader loader;
+ private final ClassLoader loader1;
+ private final ClassLoader loader2;
+ private final ClassLoader loader3;
- private CustomObjectInputStream(InputStream in, ClassLoader loader) throws IOException {
+ private CustomObjectInputStream(
+ InputStream in,
+ ClassLoader loader1,
+ ClassLoader loader2,
+ ClassLoader loader3) throws IOException {
super( in );
- this.loader = loader;
+ this.loader1 = loader1;
+ this.loader2 = loader2;
+ this.loader3 = loader3;
}
+ /**
+ * {@inheritDoc}
+ */
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException {
String className = v.getName();
- log.trace("Attempting to locate class [" + className + "]");
+ log.trace( "Attempting to locate class [" + className + "]" );
- if ( loader != null ) {
+ try {
+ return Class.forName( className, false, loader1 );
+ }
+ catch ( ClassNotFoundException e ) {
+ log.trace( "Unable to locate class using given classloader" );
+ }
+
+ if ( different( loader1, loader2 ) ) {
try {
- return Class.forName( className, false, loader );
+ return Class.forName( className, false, loader2 );
}
- catch (ClassNotFoundException e) {
+ catch ( ClassNotFoundException e ) {
log.trace( "Unable to locate class using given classloader" );
}
}
+ if ( different( loader1, loader3 ) && different( loader2, loader3 ) ) {
+ try {
+ return Class.forName( className, false, loader2 );
+ }
+ catch ( ClassNotFoundException e ) {
+ log.trace( "Unable to locate class using given classloader" );
+ }
+ }
+
+ // By default delegate to normal JDK deserialization which will use the class loader
+ // of the class which is calling this deserialization.
return super.resolveClass( v );
}
+
+ private boolean different(ClassLoader one, ClassLoader other) {
+ if ( one == null ) {
+ return other != null;
+ }
+ else {
+ return !one.equals( other );
+ }
+ }
}
}
14 years
Hibernate SVN: r19489 - core/tags.
by hibernate-commits@lists.jboss.org
Author: smendenh(a)redhat.com
Date: 2010-05-12 16:51:40 -0400 (Wed, 12 May 2010)
New Revision: 19489
Added:
core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302/
Removed:
core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4300/
Log:
Copied: core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4302 (from rev 19488, core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4300)
14 years
Hibernate SVN: r19488 - core/trunk/core/src/main/java/org/hibernate/id.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-12 16:45:00 -0400 (Wed, 12 May 2010)
New Revision: 19488
Modified:
core/trunk/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java
Log:
HHH-5042 - TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range
Modified: core/trunk/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java 2010-05-12 20:42:35 UTC (rev 19487)
+++ core/trunk/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java 2010-05-12 20:45:00 UTC (rev 19488)
@@ -279,6 +279,8 @@
maxLo = PropertiesHelper.getInt(MAX_LO, params, Short.MAX_VALUE);
returnClass = type.getReturnedClass();
- hiloOptimizer = new OptimizerFactory.LegacyHiLoAlgorithmOptimizer( returnClass, maxLo );
+ if ( maxLo >= 1 ) {
+ hiloOptimizer = new OptimizerFactory.LegacyHiLoAlgorithmOptimizer( returnClass, maxLo );
+ }
}
}
14 years
Hibernate SVN: r19487 - core/branches/Branch_3_5/core/src/main/java/org/hibernate/id.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-12 16:42:35 -0400 (Wed, 12 May 2010)
New Revision: 19487
Modified:
core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java
Log:
HHH-5042 - TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java 2010-05-12 20:35:55 UTC (rev 19486)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java 2010-05-12 20:42:35 UTC (rev 19487)
@@ -279,6 +279,8 @@
maxLo = PropertiesHelper.getInt(MAX_LO, params, Short.MAX_VALUE);
returnClass = type.getReturnedClass();
- hiloOptimizer = new OptimizerFactory.LegacyHiLoAlgorithmOptimizer( returnClass, maxLo );
+ if ( maxLo >= 1 ) {
+ hiloOptimizer = new OptimizerFactory.LegacyHiLoAlgorithmOptimizer( returnClass, maxLo );
+ }
}
}
14 years
Hibernate SVN: r19486 - core/tags.
by hibernate-commits@lists.jboss.org
Author: smendenh(a)redhat.com
Date: 2010-05-12 16:35:55 -0400 (Wed, 12 May 2010)
New Revision: 19486
Added:
core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4300/
Log:
Patch branch for JBPAPP-4300
Copied: core/tags/hibernate-3.3.2.GA_CP01_JBPAPP-4300 (from rev 19485, core/tags/hibernate-3.3.2.GA_CP01)
14 years
Hibernate SVN: r19484 - core/trunk/core/src/test/java/org/hibernate/type.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-12 15:51:26 -0400 (Wed, 12 May 2010)
New Revision: 19484
Modified:
core/trunk/core/src/test/java/org/hibernate/type/TypeTest.java
Log:
HHH-5138 - Redesign types + introduce TypeRegistry & TypeResolver
Modified: core/trunk/core/src/test/java/org/hibernate/type/TypeTest.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/type/TypeTest.java 2010-05-12 19:48:43 UTC (rev 19483)
+++ core/trunk/core/src/test/java/org/hibernate/type/TypeTest.java 2010-05-12 19:51:26 UTC (rev 19484)
@@ -226,11 +226,12 @@
}
}
public void testSerializableType() {
- final Serializable original = new SerializableImpl(1);
- final Serializable copy = new SerializableImpl(1);
- final Serializable different = new SerializableImpl(2);
+ final SerializableImpl original = new SerializableImpl(1);
+ final SerializableImpl copy = new SerializableImpl(1);
+ final SerializableImpl different = new SerializableImpl(2);
runBasicTests( SerializableType.INSTANCE, original, copy, different );
+ runBasicTests( new SerializableType<SerializableImpl>( SerializableImpl.class ), original, copy, different );
}
public void testShortType() {
14 years
Hibernate SVN: r19483 - core/trunk/core/src/main/java/org/hibernate/type/descriptor/java.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-12 15:48:43 -0400 (Wed, 12 May 2010)
New Revision: 19483
Modified:
core/trunk/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java
Log:
HHH-5138 - Redesign types + introduce TypeRegistry & TypeResolver
Modified: core/trunk/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java 2010-05-12 19:12:12 UTC (rev 19482)
+++ core/trunk/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java 2010-05-12 19:48:43 UTC (rev 19483)
@@ -37,18 +37,33 @@
* @author Steve Ebersole
*/
public class SerializableTypeDescriptor<T extends Serializable> extends AbstractTypeDescriptor<T> {
+
// unfortunately the param types cannot be the same so use something other than 'T' here to make that obvious
public static class SerializableMutabilityPlan<S extends Serializable> extends MutableMutabilityPlan<S> {
- public static final SerializableMutabilityPlan INSTANCE = new SerializableMutabilityPlan();
+ private final Class<S> type;
+
+ public static final SerializableMutabilityPlan<Serializable> INSTANCE
+ = new SerializableMutabilityPlan<Serializable>( Serializable.class );
+
+ public SerializableMutabilityPlan(Class<S> type) {
+ this.type = type;
+ }
+
@SuppressWarnings({ "unchecked" })
public S deepCopyNotNull(S value) {
return (S) SerializationHelper.clone( value );
}
+
}
@SuppressWarnings({ "unchecked" })
public SerializableTypeDescriptor(Class<T> type) {
- super( type, SerializableMutabilityPlan.INSTANCE );
+ super(
+ type,
+ Serializable.class.equals( type )
+ ? (MutabilityPlan<T>) SerializableMutabilityPlan.INSTANCE
+ : new SerializableMutabilityPlan<T>( type )
+ );
}
public String toString(T value) {
14 years
Hibernate SVN: r19482 - in core/branches/Branch_3_5/envers: src/main/java/org/hibernate/envers/configuration/metadata and 11 other directories.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2010-05-12 15:12:12 -0400 (Wed, 12 May 2010)
New Revision: 19482
Added:
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java
core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/
core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/
core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml
core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/
core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/
core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml
Removed:
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java
core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/
core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml
core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/
core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml
Modified:
core/branches/Branch_3_5/envers/pom.xml
core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/CompositeTestUserType.java
core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/ParametrizedTestUserType.java
core/branches/Branch_3_5/envers/src/test/resources/testng.xml
Log:
svn merge -r 19255:19481 https://svn.jboss.org/repos/hibernate/core/trunk/envers .
Modified: core/branches/Branch_3_5/envers/pom.xml
===================================================================
--- core/branches/Branch_3_5/envers/pom.xml 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/pom.xml 2010-05-12 19:12:12 UTC (rev 19482)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.5.2-SNAPSHOT</version>
+ <version>3.6.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java
===================================================================
--- core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/BasicMetadataGenerator.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -33,10 +33,9 @@
import org.hibernate.mapping.Column;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
+import org.hibernate.type.BasicType;
import org.hibernate.type.CompositeCustomType;
import org.hibernate.type.CustomType;
-import org.hibernate.type.ImmutableType;
-import org.hibernate.type.MutableType;
import org.hibernate.type.Type;
/**
@@ -48,7 +47,7 @@
Value value, SimpleMapperBuilder mapper, boolean insertable, boolean key) {
Type type = value.getType();
- if (type instanceof ImmutableType || type instanceof MutableType) {
+ if ( type instanceof BasicType ) {
addSimpleValue(parent, propertyAuditingData, value, mapper, insertable, key);
} else if (type instanceof CustomType || type instanceof CompositeCustomType) {
addCustomValue(parent, propertyAuditingData, value, mapper, insertable, key);
Modified: core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
--- core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -80,6 +80,7 @@
/**
* Generates metadata for a collection-valued property.
* @author Adam Warski (adam at warski dot org)
+ * @author Hern�n Chanfreau
*/
public final class CollectionMetadataGenerator {
private static final Logger log = LoggerFactory.getLogger(CollectionMetadataGenerator.class);
@@ -533,7 +534,6 @@
return middleEntityXmlId;
}
- @SuppressWarnings({"unchecked"})
private String getMappedBy(Collection collectionValue) {
PersistentClass referencedClass = ((OneToMany) collectionValue.getElement()).getAssociatedClass();
@@ -543,8 +543,31 @@
return auditMappedBy;
}
+ // searching in referenced class
+ String mappedBy = this.searchMappedBy(referencedClass, collectionValue);
+
+ if(mappedBy == null) {
+ log.debug("Going to search the mapped by attribute for " + propertyName + " in superclasses of entity: " + referencedClass.getClassName());
+
+ PersistentClass tempClass = referencedClass;
+ while ((mappedBy == null) && (tempClass.getSuperclass() != null)) {
+ log.debug("Searching in superclass: " + tempClass.getSuperclass().getClassName());
+ mappedBy = this.searchMappedBy(tempClass.getSuperclass(), collectionValue);
+ tempClass = tempClass.getSuperclass();
+ }
+ }
+
+ if(mappedBy == null) {
+ throw new MappingException("Unable to read the mapped by attribute for " + propertyName + " in "
+ + referencedClass.getClassName() + "!");
+ }
+
+ return mappedBy;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private String searchMappedBy(PersistentClass referencedClass, Collection collectionValue) {
Iterator<Property> assocClassProps = referencedClass.getPropertyIterator();
-
while (assocClassProps.hasNext()) {
Property property = assocClassProps.next();
@@ -552,13 +575,10 @@
collectionValue.getKey().getColumnIterator())) {
return property.getName();
}
- }
-
- throw new MappingException("Unable to read the mapped by attribute for " + propertyName + " in "
- + referencingEntityName + "!");
+ }
+ return null;
}
- @SuppressWarnings({"unchecked"})
private String getMappedBy(Table collectionTable, PersistentClass referencedClass) {
// If there's an @AuditMappedBy specified, returning it directly.
String auditMappedBy = propertyAuditingData.getAuditMappedBy();
@@ -566,6 +586,31 @@
return auditMappedBy;
}
+ // searching in referenced class
+ String mappedBy = this.searchMappedBy(referencedClass, collectionTable);
+
+ // not found on referenced class, searching on superclasses
+ if(mappedBy == null) {
+ log.debug("Going to search the mapped by attribute for " + propertyName + " in superclases of entity: " + referencedClass.getClassName());
+
+ PersistentClass tempClass = referencedClass;
+ while ((mappedBy == null) && (tempClass.getSuperclass() != null)) {
+ log.debug("Searching in superclass: " + tempClass.getSuperclass().getClassName());
+ mappedBy = this.searchMappedBy(tempClass.getSuperclass(), collectionTable);
+ tempClass = tempClass.getSuperclass();
+ }
+ }
+
+ if(mappedBy == null) {
+ throw new MappingException("Unable to read the mapped by attribute for " + propertyName + " in "
+ + referencedClass.getClassName() + "!");
+ }
+
+ return mappedBy;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ private String searchMappedBy(PersistentClass referencedClass, Table collectionTable) {
Iterator<Property> properties = referencedClass.getPropertyIterator();
while (properties.hasNext()) {
Property property = properties.next();
@@ -576,9 +621,8 @@
return property.getName();
}
}
- }
-
- throw new MappingException("Unable to read the mapped by attribute for " + propertyName + " in "
- + referencingEntityName + "!");
+ }
+ return null;
}
+
}
Modified: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/CompositeTestUserType.java
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/CompositeTestUserType.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/CompositeTestUserType.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -28,9 +28,10 @@
import java.sql.ResultSet;
import java.sql.SQLException;
-import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.engine.SessionImplementor;
+import org.hibernate.type.IntegerType;
+import org.hibernate.type.StringType;
import org.hibernate.type.Type;
import org.hibernate.usertype.CompositeUserType;
@@ -44,7 +45,7 @@
}
public Type[] getPropertyTypes() {
- return new Type[] { Hibernate.STRING, Hibernate.INTEGER };
+ return new Type[] { StringType.INSTANCE, IntegerType.INSTANCE };
}
public Object getPropertyValue(final Object component, final int property) throws HibernateException {
@@ -106,8 +107,8 @@
throws HibernateException, SQLException
{
if (value == null) {
- st.setNull(index, Hibernate.STRING.sqlType());
- st.setNull(index + 1, Hibernate.INTEGER.sqlType());
+ st.setNull(index, StringType.INSTANCE.sqlType());
+ st.setNull(index + 1, IntegerType.INSTANCE.sqlType());
} else {
final Component comp = (Component) value;
st.setString(index, comp.getProp1());
Modified: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/ParametrizedTestUserType.java
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/ParametrizedTestUserType.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/entities/customtype/ParametrizedTestUserType.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -32,6 +32,7 @@
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
+import org.hibernate.type.StringType;
import org.hibernate.usertype.ParameterizedType;
import org.hibernate.usertype.UserType;
@@ -54,7 +55,7 @@
}
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
- return Hibernate.STRING.nullSafeGet(rs, names[0]);
+ return StringType.INSTANCE.nullSafeGet( rs, names[0] );
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
@@ -66,10 +67,11 @@
if (!v.endsWith(param2)) {
v = v + param2;
}
- Hibernate.STRING.nullSafeSet(st, v, index);
- } else {
- Hibernate.STRING.nullSafeSet(st, value, index);
+ StringType.INSTANCE.nullSafeSet(st, v, index);
}
+ else {
+ StringType.INSTANCE.nullSafeSet( st, null, index );
+ }
}
public int[] sqlTypes() {
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass)
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,26 +0,0 @@
-package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import org.hibernate.envers.Audited;
-
-@Audited
-public class DetailSubclass extends DetailSuperclass {
-
- private String str2;
-
- public DetailSubclass() {
-
- }
-
- public String getStr2() {
- return str2;
- }
-
- public void setStr2(String str2) {
- this.str2 = str2;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,26 @@
+package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import org.hibernate.envers.Audited;
+
+@Audited
+public class DetailSubclass extends DetailSuperclass {
+
+ private String str2;
+
+ public DetailSubclass() {
+
+ }
+
+ public String getStr2() {
+ return str2;
+ }
+
+ public void setStr2(String str2) {
+ this.str2 = str2;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,26 +0,0 @@
-package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import org.hibernate.envers.Audited;
-
-@Audited
-public class DetailSubclass2 extends DetailSubclass {
-
- private String str3;
-
- public DetailSubclass2() {
-
- }
-
- public String getStr3() {
- return str3;
- }
-
- public void setStr3(String str3) {
- this.str3 = str3;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSubclass2.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,26 @@
+package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import org.hibernate.envers.Audited;
+
+@Audited
+public class DetailSubclass2 extends DetailSubclass {
+
+ private String str3;
+
+ public DetailSubclass2() {
+
+ }
+
+ public String getStr3() {
+ return str3;
+ }
+
+ public void setStr3(String str3) {
+ this.str3 = str3;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,38 +0,0 @@
-package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import java.util.List;
-
-import org.hibernate.envers.Audited;
-
-@Audited
-public class DetailSuperclass {
-
- private long id;
-
- private List<Master> masters;
-
- public DetailSuperclass() {
-
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public List<Master> getMasters() {
- return masters;
- }
-
- public void setMasters(List<Master> masters) {
- this.masters = masters;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/DetailSuperclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,38 @@
+package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import java.util.List;
+
+import org.hibernate.envers.Audited;
+
+@Audited
+public class DetailSuperclass {
+
+ private long id;
+
+ private List<Master> masters;
+
+ public DetailSuperclass() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public List<Master> getMasters() {
+ return masters;
+ }
+
+ public void setMasters(List<Master> masters) {
+ this.masters = masters;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,114 +0,0 @@
-package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import javax.persistence.EntityManager;
-
-import org.hibernate.ejb.Ejb3Configuration;
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-
-public class ManyToManyInverseToSuperclassTest extends AbstractEntityTest {
-
- private long m1_id;
-
- public void configure(Ejb3Configuration cfg) {
- try {
- URL url = Thread.currentThread().getContextClassLoader()
- .getResource(
- "mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml");
- cfg.addFile(new File(url.toURI()));
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- Master m1 = new Master();
- DetailSubclass det1 = new DetailSubclass2();
-
- // Revision 1
- em.getTransaction().begin();
-
- det1.setStr2("detail 1");
-
- m1.setStr("master");
- m1.setItems(new ArrayList<DetailSubclass>());
- m1.getItems().add(det1);
-
- det1.setMasters(new ArrayList<Master>());
- det1.getMasters().add(m1);
-
- em.persist(m1);
- em.getTransaction().commit();
- m1_id = m1.getId();
-
- // Revision 2
-// em.getTransaction().begin();
-//
-// m1 = em.find(Master.class, m1_id);
-//
-// det2.setStr2("detail 2");
-// det2.setParent(m1);
-// m1.getItems().add(det2);
-// em.getTransaction().commit();
-//
-// // Revision 3
-// em.getTransaction().begin();
-//
-// m1 = em.find(Master.class, m1_id);
-// m1.setStr("new master");
-//
-// det1 = m1.getItems().get(0);
-// det1.setStr2("new detail");
-// DetailSubclass det3 = new DetailSubclass2();
-// det3.setStr2("detail 3");
-// det3.setParent(m1);
-//
-// m1.getItems().get(1).setParent(null);
-// // m1.getItems().remove(1);
-// m1.getItems().add(det3);
-//
-// em.persist(m1);
-// em.getTransaction().commit();
-//
-// // Revision 4
-// em.getTransaction().begin();
-//
-// m1 = em.find(Master.class, m1_id);
-//
-// det1 = m1.getItems().get(0);
-// det1.setParent(null);
-// // m1.getItems().remove(det1);
-//
-// em.persist(m1);
-// em.getTransaction().commit();
-
- }
-
- @Test
- public void testHistoryExists() {
- Master rev1_1 = getAuditReader().find(Master.class, m1_id, 1);
- Master rev1_2 = getAuditReader().find(Master.class, m1_id, 2);
- Master rev1_3 = getAuditReader().find(Master.class, m1_id, 3);
- Master rev1_4 = getAuditReader().find(Master.class, m1_id, 4);
-
- assert (rev1_1 != null);
- assert (rev1_2 != null);
- assert (rev1_3 != null);
- assert (rev1_4 != null);
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/ManyToManyInverseToSuperclassTest.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,114 @@
+package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class ManyToManyInverseToSuperclassTest extends AbstractEntityTest {
+
+ private long m1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url = Thread.currentThread().getContextClassLoader()
+ .getResource(
+ "mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ Master m1 = new Master();
+ DetailSubclass det1 = new DetailSubclass2();
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ det1.setStr2("detail 1");
+
+ m1.setStr("master");
+ m1.setItems(new ArrayList<DetailSubclass>());
+ m1.getItems().add(det1);
+
+ det1.setMasters(new ArrayList<Master>());
+ det1.getMasters().add(m1);
+
+ em.persist(m1);
+ em.getTransaction().commit();
+ m1_id = m1.getId();
+
+ // Revision 2
+// em.getTransaction().begin();
+//
+// m1 = em.find(Master.class, m1_id);
+//
+// det2.setStr2("detail 2");
+// det2.setParent(m1);
+// m1.getItems().add(det2);
+// em.getTransaction().commit();
+//
+// // Revision 3
+// em.getTransaction().begin();
+//
+// m1 = em.find(Master.class, m1_id);
+// m1.setStr("new master");
+//
+// det1 = m1.getItems().get(0);
+// det1.setStr2("new detail");
+// DetailSubclass det3 = new DetailSubclass2();
+// det3.setStr2("detail 3");
+// det3.setParent(m1);
+//
+// m1.getItems().get(1).setParent(null);
+// // m1.getItems().remove(1);
+// m1.getItems().add(det3);
+//
+// em.persist(m1);
+// em.getTransaction().commit();
+//
+// // Revision 4
+// em.getTransaction().begin();
+//
+// m1 = em.find(Master.class, m1_id);
+//
+// det1 = m1.getItems().get(0);
+// det1.setParent(null);
+// // m1.getItems().remove(det1);
+//
+// em.persist(m1);
+// em.getTransaction().commit();
+
+ }
+
+ @Test
+ public void testHistoryExists() {
+ Master rev1_1 = getAuditReader().find(Master.class, m1_id, 1);
+ Master rev1_2 = getAuditReader().find(Master.class, m1_id, 2);
+ Master rev1_3 = getAuditReader().find(Master.class, m1_id, 3);
+ Master rev1_4 = getAuditReader().find(Master.class, m1_id, 4);
+
+ assert (rev1_1 != null);
+ assert (rev1_2 != null);
+ assert (rev1_3 != null);
+ assert (rev1_4 != null);
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,48 +0,0 @@
-package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import java.util.List;
-
-import org.hibernate.envers.Audited;
-
-@Audited
-public class Master {
-
- private long id;
-
- private String str;
-
- private List<DetailSubclass> items;
-
- public Master() {
-
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getStr() {
- return str;
- }
-
- public void setStr(String str) {
- this.str = str;
- }
-
- public List<DetailSubclass> getItems() {
- return items;
- }
-
- public void setItems(List<DetailSubclass> items) {
- this.items = items;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/manytomany/inverseToSuperclass/Master.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,48 @@
+package org.hibernate.envers.test.integration.manytomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import java.util.List;
+
+import org.hibernate.envers.Audited;
+
+@Audited
+public class Master {
+
+ private long id;
+
+ private String str;
+
+ private List<DetailSubclass> items;
+
+ public Master() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getStr() {
+ return str;
+ }
+
+ public void setStr(String str) {
+ this.str = str;
+ }
+
+ public List<DetailSubclass> getItems() {
+ return items;
+ }
+
+ public void setItems(List<DetailSubclass> items) {
+ this.items = items;
+ }
+
+}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass)
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,26 +0,0 @@
-package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import org.hibernate.envers.Audited;
-
-@Audited
-public class DetailSubclass extends DetailSuperclass {
-
- private String str2;
-
- public DetailSubclass() {
-
- }
-
- public String getStr2() {
- return str2;
- }
-
- public void setStr2(String str2) {
- this.str2 = str2;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,26 @@
+package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import org.hibernate.envers.Audited;
+
+@Audited
+public class DetailSubclass extends DetailSuperclass {
+
+ private String str2;
+
+ public DetailSubclass() {
+
+ }
+
+ public String getStr2() {
+ return str2;
+ }
+
+ public void setStr2(String str2) {
+ this.str2 = str2;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,26 +0,0 @@
-package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import org.hibernate.envers.Audited;
-
-@Audited
-public class DetailSubclass2 extends DetailSubclass {
-
- private String str3;
-
- public DetailSubclass2() {
-
- }
-
- public String getStr3() {
- return str3;
- }
-
- public void setStr3(String str3) {
- this.str3 = str3;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSubclass2.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,26 @@
+package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import org.hibernate.envers.Audited;
+
+@Audited
+public class DetailSubclass2 extends DetailSubclass {
+
+ private String str3;
+
+ public DetailSubclass2() {
+
+ }
+
+ public String getStr3() {
+ return str3;
+ }
+
+ public void setStr3(String str3) {
+ this.str3 = str3;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,36 +0,0 @@
-package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import org.hibernate.envers.Audited;
-
-@Audited
-public class DetailSuperclass {
-
- private long id;
-
- private Master parent;
-
- public DetailSuperclass() {
-
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public Master getParent() {
- return parent;
- }
-
- public void setParent(Master parent) {
- this.parent = parent;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/DetailSuperclass.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,36 @@
+package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import org.hibernate.envers.Audited;
+
+@Audited
+public class DetailSuperclass {
+
+ private long id;
+
+ private Master parent;
+
+ public DetailSuperclass() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Master getParent() {
+ return parent;
+ }
+
+ public void setParent(Master parent) {
+ this.parent = parent;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,48 +0,0 @@
-package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-import java.util.List;
-
-import org.hibernate.envers.Audited;
-
-@Audited
-public class Master {
-
- private long id;
-
- private String str;
-
- private List<DetailSubclass> items;
-
- public Master() {
-
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getStr() {
- return str;
- }
-
- public void setStr(String str) {
- this.str = str;
- }
-
- public List<DetailSubclass> getItems() {
- return items;
- }
-
- public void setItems(List<DetailSubclass> items) {
- this.items = items;
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/Master.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,48 @@
+package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+import java.util.List;
+
+import org.hibernate.envers.Audited;
+
+@Audited
+public class Master {
+
+ private long id;
+
+ private String str;
+
+ private List<DetailSubclass> items;
+
+ public Master() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getStr() {
+ return str;
+ }
+
+ public void setStr(String str) {
+ this.str = str;
+ }
+
+ public List<DetailSubclass> getItems() {
+ return items;
+ }
+
+ public void setItems(List<DetailSubclass> items) {
+ this.items = items;
+ }
+
+}
Deleted: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,113 +0,0 @@
-package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import javax.persistence.EntityManager;
-
-import org.hibernate.ejb.Ejb3Configuration;
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @author Hern�n Chanfreau
- *
- */
-
-public class OneToManyInverseToSuperclassTest extends AbstractEntityTest {
-
- private long m1_id;
-
- public void configure(Ejb3Configuration cfg) {
- try {
- URL url = Thread.currentThread().getContextClassLoader()
- .getResource(
- "mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml");
- cfg.addFile(new File(url.toURI()));
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
-
- @BeforeClass(dependsOnMethods = "init")
- public void initData() {
- EntityManager em = getEntityManager();
-
- Master m1 = new Master();
- DetailSubclass det1 = new DetailSubclass2();
- DetailSubclass det2 = new DetailSubclass2();
-
- // Revision 1
- em.getTransaction().begin();
-
- det1.setStr2("detail 1");
-
- m1.setStr("master");
- m1.setItems(new ArrayList<DetailSubclass>());
- m1.getItems().add(det1);
- det1.setParent(m1);
-
- em.persist(m1);
- em.getTransaction().commit();
- m1_id = m1.getId();
-
- // Revision 2
- em.getTransaction().begin();
-
- m1 = em.find(Master.class, m1_id);
-
- det2.setStr2("detail 2");
- det2.setParent(m1);
- m1.getItems().add(det2);
- em.getTransaction().commit();
-
- // Revision 3
- em.getTransaction().begin();
-
- m1 = em.find(Master.class, m1_id);
- m1.setStr("new master");
-
- det1 = m1.getItems().get(0);
- det1.setStr2("new detail");
- DetailSubclass det3 = new DetailSubclass2();
- det3.setStr2("detail 3");
- det3.setParent(m1);
-
- m1.getItems().get(1).setParent(null);
- // m1.getItems().remove(1);
- m1.getItems().add(det3);
-
- em.persist(m1);
- em.getTransaction().commit();
-
- // Revision 4
- em.getTransaction().begin();
-
- m1 = em.find(Master.class, m1_id);
-
- det1 = m1.getItems().get(0);
- det1.setParent(null);
- // m1.getItems().remove(det1);
-
- em.persist(m1);
- em.getTransaction().commit();
-
- }
-
- @Test
- public void testHistoryExists() {
- Master rev1_1 = getAuditReader().find(Master.class, m1_id, 1);
- Master rev1_2 = getAuditReader().find(Master.class, m1_id, 2);
- Master rev1_3 = getAuditReader().find(Master.class, m1_id, 3);
- Master rev1_4 = getAuditReader().find(Master.class, m1_id, 4);
-
- assert (rev1_1 != null);
- assert (rev1_2 != null);
- assert (rev1_3 != null);
- assert (rev1_4 != null);
- }
-
-}
Copied: core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java (from rev 19481, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/java/org/hibernate/envers/test/integration/onetomany/inverseToSuperclass/OneToManyInverseToSuperclassTest.java 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,113 @@
+package org.hibernate.envers.test.integration.onetomany.inverseToSuperclass;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class OneToManyInverseToSuperclassTest extends AbstractEntityTest {
+
+ private long m1_id;
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url = Thread.currentThread().getContextClassLoader()
+ .getResource(
+ "mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ Master m1 = new Master();
+ DetailSubclass det1 = new DetailSubclass2();
+ DetailSubclass det2 = new DetailSubclass2();
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ det1.setStr2("detail 1");
+
+ m1.setStr("master");
+ m1.setItems(new ArrayList<DetailSubclass>());
+ m1.getItems().add(det1);
+ det1.setParent(m1);
+
+ em.persist(m1);
+ em.getTransaction().commit();
+ m1_id = m1.getId();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ m1 = em.find(Master.class, m1_id);
+
+ det2.setStr2("detail 2");
+ det2.setParent(m1);
+ m1.getItems().add(det2);
+ em.getTransaction().commit();
+
+ // Revision 3
+ em.getTransaction().begin();
+
+ m1 = em.find(Master.class, m1_id);
+ m1.setStr("new master");
+
+ det1 = m1.getItems().get(0);
+ det1.setStr2("new detail");
+ DetailSubclass det3 = new DetailSubclass2();
+ det3.setStr2("detail 3");
+ det3.setParent(m1);
+
+ m1.getItems().get(1).setParent(null);
+ // m1.getItems().remove(1);
+ m1.getItems().add(det3);
+
+ em.persist(m1);
+ em.getTransaction().commit();
+
+ // Revision 4
+ em.getTransaction().begin();
+
+ m1 = em.find(Master.class, m1_id);
+
+ det1 = m1.getItems().get(0);
+ det1.setParent(null);
+ // m1.getItems().remove(det1);
+
+ em.persist(m1);
+ em.getTransaction().commit();
+
+ }
+
+ @Test
+ public void testHistoryExists() {
+ Master rev1_1 = getAuditReader().find(Master.class, m1_id, 1);
+ Master rev1_2 = getAuditReader().find(Master.class, m1_id, 2);
+ Master rev1_3 = getAuditReader().find(Master.class, m1_id, 3);
+ Master rev1_4 = getAuditReader().find(Master.class, m1_id, 4);
+
+ assert (rev1_1 != null);
+ assert (rev1_2 != null);
+ assert (rev1_3 != null);
+ assert (rev1_4 != null);
+ }
+
+}
Copied: core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany (from rev 19481, core/trunk/envers/src/test/resources/mappings/manyToMany)
Copied: core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass (from rev 19481, core/trunk/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass)
Deleted: core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml
===================================================================
--- core/trunk/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="WINDOWS-1251"?>
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
-
- <class
- name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
- table="HIB_MASTER_ENTITY">
-
- <id name="id" column="ID" type="long">
- <generator class="increment" />
- </id>
-
- <property name="str" column="STR" />
-
- <bag name="items" lazy="true" cascade="all" access="property" inverse="true"
- table="HIB_MASTER_DETAIL">
- <key column="ID_MASTER" />
- <many-to-many
- class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
- column="ID_DETAIL" />
- </bag>
- </class>
-
-
- <class
- name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSuperclass"
- table="HIB_DETAIL_ENTITY" abstract="true">
- <id name="id" column="ID" type="long">
- <generator class="increment" />
- </id>
- <discriminator column="DISCRIMINATOR" type="string" />
-
- <bag name="masters" lazy="true" access="property" table="HIB_MASTER_DETAIL">
- <key column="ID_DETAIL" />
- <many-to-many
- class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
- column="ID_MASTER" />
- </bag>
-
- <subclass
- name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass"
- discriminator-value="SUB">
- <property name="str2" column="STR2" />
-
- <subclass
- name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
- discriminator-value="SUB2"
- extends="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass">
- <property name="str3" column="STR3" />
-
- </subclass>
-
- </subclass>
- </class>
-
-
-</hibernate-mapping>
Copied: core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml (from rev 19481, core/trunk/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/resources/mappings/manyToMany/inverseToSuperclass/mappings.hbm.xml 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
+ table="HIB_MASTER_ENTITY">
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="str" column="STR" />
+
+ <bag name="items" lazy="true" cascade="all" access="property" inverse="true"
+ table="HIB_MASTER_DETAIL">
+ <key column="ID_MASTER" />
+ <many-to-many
+ class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
+ column="ID_DETAIL" />
+ </bag>
+ </class>
+
+
+ <class
+ name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSuperclass"
+ table="HIB_DETAIL_ENTITY" abstract="true">
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+ <discriminator column="DISCRIMINATOR" type="string" />
+
+ <bag name="masters" lazy="true" access="property" table="HIB_MASTER_DETAIL">
+ <key column="ID_DETAIL" />
+ <many-to-many
+ class="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.Master"
+ column="ID_MASTER" />
+ </bag>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass"
+ discriminator-value="SUB">
+ <property name="str2" column="STR2" />
+
+ <subclass
+ name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass2"
+ discriminator-value="SUB2"
+ extends="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass.DetailSubclass">
+ <property name="str3" column="STR3" />
+
+ </subclass>
+
+ </subclass>
+ </class>
+
+
+</hibernate-mapping>
Copied: core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany (from rev 19481, core/trunk/envers/src/test/resources/mappings/oneToMany)
Copied: core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass (from rev 19481, core/trunk/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass)
Deleted: core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml
===================================================================
--- core/trunk/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml 2010-05-12 19:12:12 UTC (rev 19482)
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="WINDOWS-1251"?>
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
-
- <class
- name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master"
- table="HIB_MASTER_ENTITY">
-
- <id name="id" column="ID" type="long">
- <generator class="increment" />
- </id>
-
- <property name="str" column="STR" />
-
- <bag name="items" lazy="true" cascade="all" access="property"
- inverse="true">
- <key column="ID_MASTER" />
- <one-to-many
- class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2" />
- </bag>
- </class>
-
-
- <class
- name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSuperclass"
- table="HIB_DETAIL_ENTITY" abstract="true">
- <id name="id" column="ID" type="long">
- <generator class="increment" />
- </id>
- <discriminator column="DISCRIMINATOR" type="string" />
-
- <many-to-one name="parent" column="ID_MASTER"
- class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master" />
-
- <subclass
- name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass"
- discriminator-value="SUB">
- <property name="str2" column="STR2" />
-
- <subclass
- name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2"
- discriminator-value="SUB2" extends="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass">
- <property name="str3" column="STR3" />
-
- </subclass>
-
- </subclass>
- </class>
-
-
-</hibernate-mapping>
Copied: core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml (from rev 19481, core/trunk/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml)
===================================================================
--- core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml (rev 0)
+++ core/branches/Branch_3_5/envers/src/test/resources/mappings/oneToMany/inverseToSuperclass/mappings.hbm.xml 2010-05-12 19:12:12 UTC (rev 19482)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master"
+ table="HIB_MASTER_ENTITY">
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="str" column="STR" />
+
+ <bag name="items" lazy="true" cascade="all" access="property"
+ inverse="true">
+ <key column="ID_MASTER" />
+ <one-to-many
+ class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2" />
+ </bag>
+ </class>
+
+
+ <class
+ name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSuperclass"
+ table="HIB_DETAIL_ENTITY" abstract="true">
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+ <discriminator column="DISCRIMINATOR" type="string" />
+
+ <many-to-one name="parent" column="ID_MASTER"
+ class="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.Master" />
+
+ <subclass
+ name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass"
+ discriminator-value="SUB">
+ <property name="str2" column="STR2" />
+
+ <subclass
+ name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass2"
+ discriminator-value="SUB2" extends="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass.DetailSubclass">
+ <property name="str3" column="STR3" />
+
+ </subclass>
+
+ </subclass>
+ </class>
+
+
+</hibernate-mapping>
Modified: core/branches/Branch_3_5/envers/src/test/resources/testng.xml
===================================================================
--- core/branches/Branch_3_5/envers/src/test/resources/testng.xml 2010-05-12 18:27:16 UTC (rev 19481)
+++ core/branches/Branch_3_5/envers/src/test/resources/testng.xml 2010-05-12 19:12:12 UTC (rev 19482)
@@ -43,6 +43,7 @@
<package name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.union" />
<package name="org.hibernate.envers.test.integration.manytomany" />
<package name="org.hibernate.envers.test.integration.manytomany.biowned" />
+ <package name="org.hibernate.envers.test.integration.manytomany.inverseToSuperclass" />
<package name="org.hibernate.envers.test.integration.manytomany.sametable" />
<package name="org.hibernate.envers.test.integration.manytomany.ternary" />
<package name="org.hibernate.envers.test.integration.manytomany.unidirectional" />
@@ -53,6 +54,7 @@
<package name="org.hibernate.envers.test.integration.notinsertable.manytoone" />
<package name="org.hibernate.envers.test.integration.onetomany" />
<package name="org.hibernate.envers.test.integration.onetomany.detached" />
+ <package name="org.hibernate.envers.test.integration.onetomany.inverseToSuperclass" />
<package name="org.hibernate.envers.test.integration.onetoone.bidirectional" />
<package name="org.hibernate.envers.test.integration.onetoone.bidirectional.ids" />
<package name="org.hibernate.envers.test.integration.onetoone.unidirectional" />
14 years
Hibernate SVN: r19481 - in core/trunk/core/src: main/java/org/hibernate/id/enhanced and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-12 14:27:16 -0400 (Wed, 12 May 2010)
New Revision: 19481
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
core/trunk/core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
core/trunk/core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java
core/trunk/core/src/main/java/org/hibernate/mapping/SimpleValue.java
core/trunk/core/src/test/java/org/hibernate/id/enhanced/OptimizerUnitTest.java
core/trunk/core/src/test/java/org/hibernate/id/enhanced/SequenceStyleConfigUnitTest.java
Log:
HHH-5218 - Provide a new "pooled value" based optimizer which interprets the database value as the low boundary instead of upper boundary
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -519,6 +519,12 @@
public static final String JPAQL_STRICT_COMPLIANCE= "hibernate.query.jpaql_strict_compliance";
+ /**
+ * When using pooled {@link org.hibernate.id.enhanced.Optimizer optimizers}, prefer interpreting the
+ * database value as the lower (lo) boundary. The default is to interpret it as the high boundary.
+ */
+ public static final String PREFER_POOLED_VALUES_LO = "hibernate.id.optimizer.pooled.prefer_lo";
+
private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
private static final boolean ENABLE_BINARY_STREAMS;
private static final boolean ENABLE_REFLECTION_OPTIMIZER;
Modified: core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * 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 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.id.enhanced;
@@ -46,6 +45,7 @@
public static final String HILO = "hilo";
public static final String LEGACY_HILO = "legacy-hilo";
public static final String POOL = "pooled";
+ public static final String POOL_LO = "pooled-lo";
private static Class[] CTOR_SIG = new Class[] { Class.class, int.class };
@@ -93,6 +93,9 @@
else if ( POOL.equals( type ) ) {
optimizerClassName = PooledOptimizer.class.getName();
}
+ else if ( POOL_LO.equals( type ) ) {
+ optimizerClassName = PooledLoOptimizer.class.getName();
+ }
else {
optimizerClassName = type;
}
@@ -387,6 +390,9 @@
* Note that this optimizer works essentially the same as the
* {@link HiLoOptimizer} except that here the bucket ranges are actually
* encoded into the database structures.
+ * <p/>
+ * Note if you prefer that the database value be interpreted as the bottom end of our current range,
+ * then use the {@link PooledLoOptimizer} strategy
*/
public static class PooledOptimizer extends OptimizerSupport implements InitialValueAwareOptimizer {
private IntegralDataTypeHolder hiValue;
@@ -464,4 +470,39 @@
this.initialValue = initialValue;
}
}
+
+ public static class PooledLoOptimizer extends OptimizerSupport {
+ private IntegralDataTypeHolder lastSourceValue; // last value read from db source
+ private IntegralDataTypeHolder value; // the current generator value
+
+ public PooledLoOptimizer(Class returnClass, int incrementSize) {
+ super( returnClass, incrementSize );
+ if ( incrementSize < 1 ) {
+ throw new HibernateException( "increment size cannot be less than 1" );
+ }
+ if ( log.isTraceEnabled() ) {
+ log.trace( "creating pooled optimizer (lo) with [incrementSize=" + incrementSize + "; returnClass=" + returnClass.getName() + "]" );
+ }
+ }
+
+ public Serializable generate(AccessCallback callback) {
+ if ( lastSourceValue == null || ! value.lt( lastSourceValue.copy().add( incrementSize ) ) ) {
+ lastSourceValue = callback.getNextValue();
+ value = lastSourceValue.copy();
+ // handle cases where initial-value is less that one (hsqldb for instance).
+ while ( value.lt( 1 ) ) {
+ value.increment();
+ }
+ }
+ return value.makeValueThenIncrement();
+ }
+
+ public IntegralDataTypeHolder getLastSourceValue() {
+ return lastSourceValue;
+ }
+
+ public boolean applyIncrementSizeToSourceValues() {
+ return true;
+ }
+ }
}
Modified: core/trunk/core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * 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 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.id.enhanced;
@@ -30,6 +29,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.hibernate.cfg.Environment;
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.id.Configurable;
import org.hibernate.HibernateException;
@@ -280,8 +280,13 @@
* @return The optimizer strategy (name)
*/
protected String determineOptimizationStrategy(Properties params, int incrementSize) {
- String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
- return PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
+ // if the increment size is greater than one, we prefer pooled optimization; but we
+ // need to see if the user prefers POOL or POOL_LO...
+ String defaultPooledOptimizerStrategy = PropertiesHelper.getBoolean( Environment.PREFER_POOLED_VALUES_LO, params, false )
+ ? OptimizerFactory.POOL_LO
+ : OptimizerFactory.POOL;
+ String defaultOptimizerStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : defaultPooledOptimizerStrategy;
+ return PropertiesHelper.getString( OPT_PARAM, params, defaultOptimizerStrategy );
}
/**
Modified: core/trunk/core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * 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 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.id.enhanced;
@@ -37,6 +36,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.hibernate.cfg.Environment;
import org.hibernate.engine.TransactionHelper;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.id.IdentifierGeneratorHelper;
@@ -65,14 +65,14 @@
* performing generation, which would mean that we would have a row in the generator
* table for each entity name. Or any configuration really; the setup is very flexible.
* <p/>
- * In this respect it is very simliar to the legacy
+ * In this respect it is very similar to the legacy
* {@link org.hibernate.id.MultipleHiLoPerTableGenerator} in terms of the
* underlying storage structure (namely a single table capable of holding
* multiple generator values). The differentiator is, as with
* {@link SequenceStyleGenerator} as well, the externalized notion
* of an optimizer.
* <p/>
- * <b>NOTE</b> that by default we use a single row for all genertators (based
+ * <b>NOTE</b> that by default we use a single row for all generators (based
* on {@link #DEF_SEGMENT_VALUE}). The configuration parameter
* {@link #CONFIG_PREFER_SEGMENT_PER_ENTITY} can be used to change that to
* instead default to using a row for each entity name.
@@ -303,8 +303,13 @@
this.updateQuery = buildUpdateQuery();
this.insertQuery = buildInsertQuery();
- final String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL;
- final String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy );
+ // if the increment size is greater than one, we prefer pooled optimization; but we
+ // need to see if the user prefers POOL or POOL_LO...
+ String defaultPooledOptimizerStrategy = PropertiesHelper.getBoolean( Environment.PREFER_POOLED_VALUES_LO, params, false )
+ ? OptimizerFactory.POOL_LO
+ : OptimizerFactory.POOL;
+ final String defaultOptimizerStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : defaultPooledOptimizerStrategy;
+ final String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defaultOptimizerStrategy );
optimizer = OptimizerFactory.buildOptimizer(
optimizationStrategy,
identifierType.getReturnedClass(),
Modified: core/trunk/core/src/main/java/org/hibernate/mapping/SimpleValue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/mapping/SimpleValue.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/main/java/org/hibernate/mapping/SimpleValue.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -30,6 +30,7 @@
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
+import org.hibernate.cfg.Environment;
import org.hibernate.cfg.Mappings;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.Mapping;
@@ -182,6 +183,12 @@
params.putAll(identifierGeneratorProperties);
}
+ // TODO : we should pass along all settings once "config lifecycle" is hashed out...
+ params.put(
+ Environment.PREFER_POOLED_VALUES_LO,
+ mappings.getConfigurationProperties().getProperty( Environment.PREFER_POOLED_VALUES_LO, "false" )
+ );
+
identifierGeneratorFactory.setDialect( dialect );
return identifierGeneratorFactory.createIdentifierGenerator( identifierGeneratorStrategy, getType(), params );
Modified: core/trunk/core/src/test/java/org/hibernate/id/enhanced/OptimizerUnitTest.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/id/enhanced/OptimizerUnitTest.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/test/java/org/hibernate/id/enhanced/OptimizerUnitTest.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -123,35 +123,136 @@
public void testSubsequentPooledOptimizerUsage() {
// test the pooled optimizer in situation where the sequence is already beyond its initial value on init.
// cheat by telling the sequence to start with 1000
- final SourceMock sequence = new SourceMock( 1000, 3, 5 );
+ final SourceMock sequence = new SourceMock( 1001, 3, 5 );
// but tell the optimizer the start-with is 1
final Optimizer optimizer = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL, Long.class, 3, 1 );
assertEquals( 5, sequence.getTimesCalled() );
- assertEquals( 1000, sequence.getCurrentValue() );
+ assertEquals( 1001, sequence.getCurrentValue() );
Long next = (Long) optimizer.generate( sequence );
- assertEquals( 1000, next.intValue() );
+ assertEquals( 1001, next.intValue() );
assertEquals( (5+1), sequence.getTimesCalled() );
- assertEquals( (1000+3), sequence.getCurrentValue() );
+ assertEquals( (1001+3), sequence.getCurrentValue() );
next = (Long) optimizer.generate( sequence );
- assertEquals( 1001, next.intValue() );
+ assertEquals( (1001+1), next.intValue() );
assertEquals( (5+1), sequence.getTimesCalled() );
- assertEquals( (1000+3), sequence.getCurrentValue() );
+ assertEquals( (1001+3), sequence.getCurrentValue() );
next = (Long) optimizer.generate( sequence );
- assertEquals( 1002, next.intValue() );
+ assertEquals( (1001+2), next.intValue() );
assertEquals( (5+1), sequence.getTimesCalled() );
- assertEquals( (1000+3), sequence.getCurrentValue() );
+ assertEquals( (1001+3), sequence.getCurrentValue() );
// force a "clock over"
next = (Long) optimizer.generate( sequence );
- assertEquals( 1003, next.intValue() );
+ assertEquals( (1001+3), next.intValue() );
assertEquals( (5+2), sequence.getTimesCalled() );
- assertEquals( (1000+6), sequence.getCurrentValue() );
+ assertEquals( (1001+6), sequence.getCurrentValue() );
}
+ public void testBasicPooledLoOptimizerUsage() {
+ final SourceMock sequence = new SourceMock( 1, 3 );
+ final Optimizer optimizer = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL_LO, Long.class, 3 );
+
+ assertEquals( 0, sequence.getTimesCalled() );
+ assertEquals( -1, sequence.getCurrentValue() );
+
+ Long next = ( Long ) optimizer.generate( sequence );
+ assertEquals( 1, next.intValue() );
+ assertEquals( 1, sequence.getTimesCalled() );
+ assertEquals( 1, sequence.getCurrentValue() );
+
+ next = ( Long ) optimizer.generate( sequence );
+ assertEquals( 2, next.intValue() );
+ assertEquals( 1, sequence.getTimesCalled() );
+ assertEquals( 1, sequence.getCurrentValue() );
+
+ next = ( Long ) optimizer.generate( sequence );
+ assertEquals( 3, next.intValue() );
+ assertEquals( 1, sequence.getTimesCalled() );
+ assertEquals( 1, sequence.getCurrentValue() );
+
+// // force a "clock over"
+ next = ( Long ) optimizer.generate( sequence );
+ assertEquals( 4, next.intValue() );
+ assertEquals( 2, sequence.getTimesCalled() );
+ assertEquals( (1+3), sequence.getCurrentValue() );
+ }
+
+ public void testSubsequentPooledLoOptimizerUsage() {
+ // test the pooled optimizer in situation where the sequence is already beyond its initial value on init.
+ // cheat by telling the sequence to start with 1000
+ final SourceMock sequence = new SourceMock( 1001, 3, 5 );
+ // but tell the optimizer the start-with is 1
+ final Optimizer optimizer = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL, Long.class, 3, 1 );
+
+ assertEquals( 5, sequence.getTimesCalled() );
+ assertEquals( 1001, sequence.getCurrentValue() );
+
+ Long next = ( Long ) optimizer.generate( sequence );
+ assertEquals( (1001), next.intValue() );
+ assertEquals( (5+1), sequence.getTimesCalled() );
+ assertEquals( (1001+3), sequence.getCurrentValue() );
+
+ next = ( Long ) optimizer.generate( sequence );
+ assertEquals( (1001+1), next.intValue() );
+ assertEquals( (5+1), sequence.getTimesCalled() );
+ assertEquals( (1001+3), sequence.getCurrentValue() );
+
+ next = ( Long ) optimizer.generate( sequence );
+ assertEquals( (1001+2), next.intValue() );
+ assertEquals( (5+1), sequence.getTimesCalled() );
+ assertEquals( (1001+3), sequence.getCurrentValue() );
+
+// // force a "clock over"
+ next = ( Long ) optimizer.generate( sequence );
+ assertEquals( (1001+3), next.intValue() );
+ assertEquals( (5+2), sequence.getTimesCalled() );
+ assertEquals( (1001+6), sequence.getCurrentValue() );
+ }
+
+ public void testRecoveredPooledOptimizerUsage() {
+ final SourceMock sequence = new SourceMock( 1, 3 );
+ final Optimizer optimizer = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL, Long.class, 3, 1 );
+
+ assertEquals( 0, sequence.getTimesCalled() );
+ assertEquals( -1, sequence.getCurrentValue() );
+
+ Long next = ( Long ) optimizer.generate( sequence );
+ assertEquals( 1, next.intValue() );
+ assertEquals( 2, sequence.getTimesCalled() );
+ assertEquals( 4, sequence.getCurrentValue() );
+
+ // app ends, and starts back up (we should "lose" only 2 and 3 as id values)
+ final Optimizer optimizer2 = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL, Long.class, 3, 1 );
+ next = ( Long ) optimizer2.generate( sequence );
+ assertEquals( 4, next.intValue() );
+ assertEquals( 3, sequence.getTimesCalled() );
+ assertEquals( 7, sequence.getCurrentValue() );
+ }
+
+ public void testRecoveredPooledLoOptimizerUsage() {
+ final SourceMock sequence = new SourceMock( 1, 3 );
+ final Optimizer optimizer = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL_LO, Long.class, 3, 1 );
+
+ assertEquals( 0, sequence.getTimesCalled() );
+ assertEquals( -1, sequence.getCurrentValue() );
+
+ Long next = ( Long ) optimizer.generate( sequence );
+ assertEquals( 1, next.intValue() );
+ assertEquals( 1, sequence.getTimesCalled() );
+ assertEquals( 1, sequence.getCurrentValue() );
+
+ // app ends, and starts back up (we should "lose" only 2 and 3 as id values)
+ final Optimizer optimizer2 = OptimizerFactory.buildOptimizer( OptimizerFactory.POOL_LO, Long.class, 3, 1 );
+ next = ( Long ) optimizer2.generate( sequence );
+ assertEquals( 4, next.intValue() );
+ assertEquals( 2, sequence.getTimesCalled() );
+ assertEquals( 4, sequence.getCurrentValue() );
+ }
+
private static class SourceMock implements AccessCallback {
private IdentifierGeneratorHelper.BasicHolder value = new IdentifierGeneratorHelper.BasicHolder( Long.class );
private long initialValue;
@@ -174,6 +275,7 @@
this.initialValue = 1;
}
else {
+ this.value.initialize( -1 );
this.initialValue = initialValue;
}
}
Modified: core/trunk/core/src/test/java/org/hibernate/id/enhanced/SequenceStyleConfigUnitTest.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/id/enhanced/SequenceStyleConfigUnitTest.java 2010-05-12 18:19:00 UTC (rev 19480)
+++ core/trunk/core/src/test/java/org/hibernate/id/enhanced/SequenceStyleConfigUnitTest.java 2010-05-12 18:27:16 UTC (rev 19481)
@@ -1,3 +1,26 @@
+/*
+ * 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.id.enhanced;
import java.util.Properties;
@@ -6,6 +29,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect;
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.Hibernate;
@@ -178,7 +202,23 @@
assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
assertEquals( 20, generator.getOptimizer().getIncrementSize() );
assertEquals( 20, generator.getDatabaseStructure().getIncrementSize() );
+ }
+ public void testPreferPooledLoSettingHonored() {
+ final Dialect dialect = new PooledSequenceDialect();
+
+ Properties props = buildGeneratorPropertiesBase();
+ props.setProperty( SequenceStyleGenerator.INCREMENT_PARAM, "20" );
+ SequenceStyleGenerator generator = new SequenceStyleGenerator();
+ generator.configure( Hibernate.LONG, props, dialect );
+ assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
+ assertClassAssignability( OptimizerFactory.PooledOptimizer.class, generator.getOptimizer().getClass() );
+
+ props.setProperty( Environment.PREFER_POOLED_VALUES_LO, "true" );
+ generator = new SequenceStyleGenerator();
+ generator.configure( Hibernate.LONG, props, dialect );
+ assertClassAssignability( SequenceStructure.class, generator.getDatabaseStructure().getClass() );
+ assertClassAssignability( OptimizerFactory.PooledLoOptimizer.class, generator.getOptimizer().getClass() );
}
private static class TableDialect extends Dialect {
14 years