[hibernate-commits] Hibernate SVN: r11055 - in branches/Branch_3_2/HibernateExt/metadata/src: test/org/hibernate/test/annotations/various and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jan 17 15:07:05 EST 2007


Author: epbernard
Date: 2007-01-17 15:07:04 -0500 (Wed, 17 Jan 2007)
New Revision: 11055

Modified:
   branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
   branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/various/Antenna.java
Log:
ANN-535

Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java	2007-01-17 19:35:34 UTC (rev 11054)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/cfg/annotations/PropertyBinder.java	2007-01-17 20:07:04 UTC (rev 11055)
@@ -1,20 +1,23 @@
 //$Id$
 package org.hibernate.cfg.annotations;
 
+import java.util.Iterator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hibernate.AnnotationException;
 import org.hibernate.annotations.Generated;
 import org.hibernate.annotations.GenerationTime;
 import org.hibernate.cfg.Ejb3Column;
 import org.hibernate.cfg.ExtendedMappings;
 import org.hibernate.cfg.PropertyHolder;
 import org.hibernate.mapping.Property;
+import org.hibernate.mapping.PropertyGeneration;
 import org.hibernate.mapping.SimpleValue;
 import org.hibernate.mapping.Value;
-import org.hibernate.mapping.PropertyGeneration;
+import org.hibernate.mapping.Column;
 import org.hibernate.reflection.XClass;
 import org.hibernate.reflection.XProperty;
-import org.hibernate.AnnotationException;
 import org.hibernate.util.StringHelper;
 
 /**
@@ -101,7 +104,9 @@
 		if ( log.isDebugEnabled() ) {
 			log.debug( "binding property " + name + " with lazy=" + lazy );
 		}
-		String containerClassName = holder == null ? null : holder.getClassName();
+		String containerClassName = holder == null ?
+				null :
+				holder.getClassName();
 		SimpleValueBinder value = new SimpleValueBinder();
 		value.setMappings( mappings );
 		value.setPropertyName( name );
@@ -124,35 +129,31 @@
 		prop.setName( name );
 		prop.setNodeName( name );
 		prop.setValue( value );
-		prop.setInsertable( insertable );
-		prop.setUpdateable( updatable );
 		prop.setLazy( lazy );
 		prop.setCascade( cascade );
 		prop.setPropertyAccessorName( propertyAccessorName );
-		Generated ann =  property != null ?
+		Generated ann = property != null ?
 				property.getAnnotation( Generated.class ) :
 				null;
 		GenerationTime generated = ann != null ?
 				ann.value() :
 				null;
-		if (generated != null) {
-			if ( ! GenerationTime.NEVER.equals( generated ) ) {
+		if ( generated != null ) {
+			if ( !GenerationTime.NEVER.equals( generated ) ) {
 				if ( property.isAnnotationPresent( javax.persistence.Version.class )
 						&& GenerationTime.INSERT.equals( generated ) ) {
-					throw new AnnotationException("@Generated(INSERT) on a @Version property not allowed, use ALWAYS: "
+					throw new AnnotationException( "@Generated(INSERT) on a @Version property not allowed, use ALWAYS: "
 							+ StringHelper.qualify( holder.getPath(), name ) );
 				}
-				if ( prop.isInsertable() ) {
-					throw new AnnotationException("Cannot have @Generated property and insertable columns: "
-							+ StringHelper.qualify( holder.getPath(), name ) );
+				insertable = false;
+				if ( GenerationTime.ALWAYS.equals( generated ) ) {
+					updatable = false;
 				}
-				if ( GenerationTime.ALWAYS.equals( generated ) && prop.isUpdateable() ) {
-					throw new AnnotationException("Cannot have @Generated(ALWAYS) property and updatable columns: "
-							+ StringHelper.qualify( holder.getPath(), name ) );
-				}
 				prop.setGeneration( PropertyGeneration.parse( generated.toString().toLowerCase() ) );
 			}
 		}
+		prop.setInsertable( insertable );
+		prop.setUpdateable( updatable );
 		log.trace( "Cascading " + name + " with " + cascade );
 		return prop;
 	}

Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/various/Antenna.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/various/Antenna.java	2007-01-17 19:35:34 UTC (rev 11054)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/various/Antenna.java	2007-01-17 20:07:04 UTC (rev 11055)
@@ -14,7 +14,7 @@
 @Entity
 public class Antenna {
 	@Id public Integer id;
-	@Generated(GenerationTime.ALWAYS) @Column(insertable = false, updatable = false)
+	@Generated(GenerationTime.ALWAYS) @Column()
 	public String longitude;
 
 	@Generated(GenerationTime.INSERT) @Column(insertable = false)




More information about the hibernate-commits mailing list