[hibernate-commits] Hibernate SVN: r20972 - annotations/tags/3_2_1_GA_CP03_JBPAPP-6785/src/java/org/hibernate/cfg.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Jun 28 15:34:11 EDT 2011


Author: smendenh at redhat.com
Date: 2011-06-28 15:34:11 -0400 (Tue, 28 Jun 2011)
New Revision: 20972

Modified:
   annotations/tags/3_2_1_GA_CP03_JBPAPP-6785/src/java/org/hibernate/cfg/FkSecondPass.java
Log:
patched for one-off JBPAPP-6785 from changes in http://source.jboss.org/changelog/Hibernate?cs=14383

Modified: annotations/tags/3_2_1_GA_CP03_JBPAPP-6785/src/java/org/hibernate/cfg/FkSecondPass.java
===================================================================
--- annotations/tags/3_2_1_GA_CP03_JBPAPP-6785/src/java/org/hibernate/cfg/FkSecondPass.java	2011-06-28 19:18:18 UTC (rev 20971)
+++ annotations/tags/3_2_1_GA_CP03_JBPAPP-6785/src/java/org/hibernate/cfg/FkSecondPass.java	2011-06-28 19:34:11 UTC (rev 20972)
@@ -1,6 +1,8 @@
 // $Id$
 package org.hibernate.cfg;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 import org.hibernate.AnnotationException;
 import org.hibernate.AssertionFailure;
 import org.hibernate.MappingException;
@@ -16,12 +18,22 @@
  * Enable a proper set of the FK columns in respect with the id column order
  * Allow the correct implementation of the default EJB3 values which needs both
  * sides of the association to be resolved
+ * 
+ * One-off patch for ANN_683 manually applied from http://source.jboss.org/changelog/Hibernate?cs=14383
  *
  * @author Emmanuel Bernard
  */
 public class FkSecondPass implements SecondPass {
 	private ToOne value;
 	private Ejb3JoinColumn[] columns;
+	/**
+	* unique counter is needed to differenciate 2 instances of FKSecondPass
+	* as they are compared.
+	* Fairly hacky but IBM VM sometimes returns the same hashCode for 2 different objects
+	* TODO is it doable to rely on the Ejb3JoinColumn names? Not sure at they could be inferred
+	*/
+	private int uniqueCounter;
+	private static AtomicInteger globalCounter = new AtomicInteger();
 	private boolean unique;
 	private ExtendedMappings mappings;
 	private String path;
@@ -33,14 +45,35 @@
 		this.mappings = mappings;
 		this.value = value;
 		this.columns = columns;
+		this.uniqueCounter = globalCounter.getAndIncrement();
 		this.unique = unique;
 		this.entityClassName = entityClassName;
 		this.path = entityClassName != null ? path.substring( entityClassName.length() + 1 ) : path;
 	}
+	
+	public int getUniqueCounter() {
+	    return uniqueCounter;
+	}
 
 	public ToOne getValue() {
 		return value;
 	}
+	
+	public boolean equals(Object o) {
+	    if ( this == o ) return true;
+		if ( !( o instanceof FkSecondPass ) ) return false;
+	
+		FkSecondPass that = (FkSecondPass) o;
+	
+		if ( uniqueCounter != that.uniqueCounter ) return false;
+	
+		return true;
+	}
+	
+	public int hashCode() {
+		return uniqueCounter;
+	}
+	
 
 	public boolean isInPrimaryKey() {
 		if (entityClassName == null) return false;



More information about the hibernate-commits mailing list