[hibernate-commits] Hibernate SVN: r17985 - in annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate: cfg and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Nov 16 08:01:09 EST 2009


Author: stliu
Date: 2009-11-16 08:01:09 -0500 (Mon, 16 Nov 2009)
New Revision: 17985

Modified:
   annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Immutable.java
   annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java
   annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
Log:
JBPAPP-3068 in MySQL, BLOBS should specify a length/number of bytes for fields in index

Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Immutable.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Immutable.java	2009-11-14 18:03:16 UTC (rev 17984)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/annotations/Immutable.java	2009-11-16 13:01:09 UTC (rev 17985)
@@ -4,8 +4,15 @@
 import java.lang.annotation.*;
 
 /**
- * Mark an Entity or a Collection as immutable
- * No annotation means the element is mutable
+ * Mark an Entity or a Collection as immutable. No annotation means the element is mutable.
+ * <p>
+ * An immutable entity may not be updated by the application. Updates to an immutable
+ * entity will be ignored, but no exception is thrown. &#064;Immutable  must be used on root entities only. 
+ * </p>
+ * <p>
+ * &#064;Immutable placed on a collection makes the collection immutable, meaning additions and 
+ * deletions to and from the collection are not allowed. A <i>HibernateException</i> is thrown in this case. 
+ * </p>
  *
  * @author Emmanuel Bernard
  */

Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java	2009-11-14 18:03:16 UTC (rev 17984)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/AnnotationBinder.java	2009-11-16 13:01:09 UTC (rev 17985)
@@ -714,7 +714,6 @@
 					isComponent,
 					propertyAnnotated,
 					propertyAccessor, entityBinder,
-					null,
 					true,
 					false, mappings
 			);
@@ -1277,7 +1276,7 @@
 					generatedValue.generator() :
 					BinderHelper.ANNOTATION_STRING_DEFAULT;
 			if ( isComponent ) generatorType = "assigned"; //a component must not have any generator
-			Type typeAnn = property.getAnnotation( Type.class );
+
 			bindId(
 					generatorType,
 					generator,
@@ -1288,7 +1287,6 @@
 					isComponent,
 					propertyAnnotated,
 					propertyAccessor, entityBinder,
-					typeAnn,
 					false,
 					isIdentifierMapper, mappings
 			);
@@ -1856,7 +1854,7 @@
 			Map<String, IdGenerator> localGenerators,
 			boolean isComposite,
 			boolean isPropertyAnnotated,
-			String propertyAccessor, EntityBinder entityBinder, Type typeAnn, boolean isEmbedded,
+			String propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
 			boolean isIdentifierMapper, ExtendedMappings mappings
 	) {
 		/*
@@ -1901,7 +1899,7 @@
 			value.setColumns( columns );
 			value.setPersistentClassName( persistentClassName );
 			value.setMappings( mappings );
-			value.setExplicitType( typeAnn );
+			value.setType( inferredData.getProperty(), inferredData.getClassOrElement() );
 			id = value.make();
 		}
 		rootClass.setIdentifier( id );

Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/PropertyBinder.java	2009-11-14 18:03:16 UTC (rev 17984)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/PropertyBinder.java	2009-11-16 13:01:09 UTC (rev 17985)
@@ -10,6 +10,7 @@
 import org.hibernate.annotations.Generated;
 import org.hibernate.annotations.GenerationTime;
 import org.hibernate.annotations.NaturalId;
+import org.hibernate.annotations.Immutable;
 import org.hibernate.annotations.OptimisticLock;
 import org.hibernate.annotations.common.reflection.XClass;
 import org.hibernate.annotations.common.reflection.XProperty;
@@ -73,7 +74,7 @@
 	public void setColumns(Ejb3Column[] columns) {
 		insertable = columns[0].isInsertable();
 		updatable = columns[0].isUpdatable();
-		//concsistency is checked later when we know the proeprty name
+		//consistency is checked later when we know the property name
 		this.columns = columns;
 	}
 
@@ -94,7 +95,10 @@
 	}
 
 	private void validateBind() {
-		//TODO check necessary params for a bind		
+		if (property.isAnnotationPresent(Immutable.class)) {
+			throw new AnnotationException("@Immutable on property not allowed. " +
+					"Only allowed on entity level or on a collection.");
+		}			
 	}
 
 	private void validateMake() {



More information about the hibernate-commits mailing list