[hibernate-commits] Hibernate SVN: r10659 - in trunk/Hibernate3: src/org/hibernate/cfg src/org/hibernate/mapping test/org/hibernate/test/legacy

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Oct 30 11:19:14 EST 2006


Author: max.andersen at jboss.com
Date: 2006-10-30 11:19:10 -0500 (Mon, 30 Oct 2006)
New Revision: 10659

Modified:
   trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java
   trunk/Hibernate3/src/org/hibernate/mapping/MetaAttribute.java
   trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java
   trunk/Hibernate3/test/org/hibernate/test/legacy/Wicked.hbm.xml
Log:
HBX-621 & HBX-793 meta attribute were doing a concat instead of an override.
(merge from branch_3_2)

Modified: trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java	2006-10-30 15:46:48 UTC (rev 10658)
+++ trunk/Hibernate3/src/org/hibernate/cfg/HbmBinder.java	2006-10-30 16:19:10 UTC (rev 10659)
@@ -2861,13 +2861,9 @@
 			if ( meta == null  ) {
 				meta = new MetaAttribute( name );
 				map.put( name, meta );
-			} else if (meta == inheritedAttribute) { // to prevent mutation of the inherited meta attribute.			
+			} else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793			
 				meta = new MetaAttribute( name );				
-				map.put( name, meta );
-				java.util.List values = inheritedAttribute.getValues();
-				for (Iterator iterator = values.iterator(); iterator.hasNext();) {
-					meta.addValue( (String) iterator.next() );
-				}
+				map.put( name, meta );				
 			}			
 			meta.addValue( metaNode.getText() );
 		}

Modified: trunk/Hibernate3/src/org/hibernate/mapping/MetaAttribute.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/mapping/MetaAttribute.java	2006-10-30 15:46:48 UTC (rev 10658)
+++ trunk/Hibernate3/src/org/hibernate/mapping/MetaAttribute.java	2006-10-30 16:19:10 UTC (rev 10659)
@@ -30,7 +30,9 @@
 	}
 
 	public String getValue() {
-		if ( values.size()!=1 ) throw new IllegalStateException("no unique value");
+		if ( values.size()!=1 ) {
+			throw new IllegalStateException("no unique value");
+		}
 		return (String) values.get(0);
 	}
 

Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java	2006-10-30 15:46:48 UTC (rev 10658)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/NonReflectiveBinderTest.java	2006-10-30 16:19:10 UTC (rev 10659)
@@ -104,9 +104,18 @@
 		assertNotNull(element.getMetaAttribute("global"));
 		assertNotNull(element.getMetaAttribute("componentonly"));
 		assertNotNull(element.getMetaAttribute("allcomponent"));
-		assertNotNull(element.getMetaAttribute("implements"));
 		assertNull(element.getMetaAttribute("globalnoinherit"));							
 		
+		MetaAttribute compimplements = element.getMetaAttribute("implements");
+		assertNotNull(compimplements);
+		assertEquals(compimplements.getValue(), "AnotherInterface");
+		
+		Property xp = ((Component)element.getValue()).getProperty( "x" );
+		MetaAttribute propximplements = xp.getMetaAttribute( "implements" );
+		assertNotNull(propximplements);
+		assertEquals(propximplements.getValue(), "AnotherInterface");
+		
+		
 	}
 
 	// HBX-718
@@ -118,46 +127,46 @@
 		MetaAttribute metaAttribute = cm.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(metaAttribute);
-		assertEquals( metaAttribute.getValues().size(), 2 );		
-		assertEquals( "top level", metaAttribute.getValues().get(0) );
-		assertEquals( "wicked level", metaAttribute.getValues().get(1) );
+		/*assertEquals( metaAttribute.getValues().size(), 2 );		
+		assertEquals( "top level", metaAttribute.getValues().get(0) );*/
+		assertEquals( "wicked level", metaAttribute.getValue() );
 		
 		Property property = cm.getProperty( "component" );
 		MetaAttribute propertyAttribute = property.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(propertyAttribute);
-		assertEquals( propertyAttribute.getValues().size(), 3 );
+		/*assertEquals( propertyAttribute.getValues().size(), 3 );
 		assertEquals( "top level", propertyAttribute.getValues().get(0) );
-		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
-		assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );
+		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
+		assertEquals( "monetaryamount level", propertyAttribute.getValue() );
 		
 		org.hibernate.mapping.Component component = (Component)property.getValue();
 		property = component.getProperty( "x" );
 		propertyAttribute = property.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(propertyAttribute);
-		assertEquals( propertyAttribute.getValues().size(), 4 );
+		/*assertEquals( propertyAttribute.getValues().size(), 4 );
 		assertEquals( "top level", propertyAttribute.getValues().get(0) );
 		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
-		assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );
-		assertEquals( "monetaryamount x level", propertyAttribute.getValues().get(3) );
+		assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/
+		assertEquals( "monetaryamount x level", propertyAttribute.getValue() );
 		
 		property = cm.getProperty( "sortedEmployee" );
 		propertyAttribute = property.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(propertyAttribute);
-		assertEquals( propertyAttribute.getValues().size(), 3 );
+		/*assertEquals( propertyAttribute.getValues().size(), 3 );
 		assertEquals( "top level", propertyAttribute.getValues().get(0) );
-		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
-		assertEquals( "sortedemployee level", propertyAttribute.getValues().get(2) );
+		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/
+		assertEquals( "sortedemployee level", propertyAttribute.getValue() );
 		
 		property = cm.getProperty( "anotherSet" );
 		propertyAttribute = property.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(propertyAttribute);
-		assertEquals( propertyAttribute.getValues().size(), 2 );
-		assertEquals( "top level", propertyAttribute.getValues().get(0) );
-		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
+		/*assertEquals( propertyAttribute.getValues().size(), 2 );
+		assertEquals( "top level", propertyAttribute.getValues().get(0) );*/
+		assertEquals( "wicked level", propertyAttribute.getValue() );
 				
 		Bag bag = (Bag) property.getValue();
 		component = (Component)bag.getElement(); 
@@ -165,31 +174,31 @@
 		assertEquals(4,component.getMetaAttributes().size());
 		
 		metaAttribute = component.getMetaAttribute( "globalmutated" );
-		assertEquals( metaAttribute.getValues().size(), 3 );
+		/*assertEquals( metaAttribute.getValues().size(), 3 );
 		assertEquals( "top level", metaAttribute.getValues().get(0) );
-		assertEquals( "wicked level", metaAttribute.getValues().get(1) );
-		assertEquals( "monetaryamount anotherSet composite level", metaAttribute.getValues().get(2) );		
+		assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/
+		assertEquals( "monetaryamount anotherSet composite level", metaAttribute.getValue() );		
 		
 		property = component.getProperty( "emp" );
 		propertyAttribute = property.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(propertyAttribute);
-		assertEquals( propertyAttribute.getValues().size(), 4 );
+		/*assertEquals( propertyAttribute.getValues().size(), 4 );
 		assertEquals( "top level", propertyAttribute.getValues().get(0) );
 		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
-		assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );
-		assertEquals( "monetaryamount anotherSet composite property emp level", propertyAttribute.getValues().get(3) );
+		assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
+		assertEquals( "monetaryamount anotherSet composite property emp level", propertyAttribute.getValue() );
 		
 		
 		property = component.getProperty( "empinone" );
 		propertyAttribute = property.getMetaAttribute( "globalmutated" );
 		
 		assertNotNull(propertyAttribute);
-		assertEquals( propertyAttribute.getValues().size(), 4 );
+		/*assertEquals( propertyAttribute.getValues().size(), 4 );
 		assertEquals( "top level", propertyAttribute.getValues().get(0) );
 		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );
-		assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );
-		assertEquals( "monetaryamount anotherSet composite property empinone level", propertyAttribute.getValues().get(3) );
+		assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/
+		assertEquals( "monetaryamount anotherSet composite property empinone level", propertyAttribute.getValue() );
 		
 		
 	}

Modified: trunk/Hibernate3/test/org/hibernate/test/legacy/Wicked.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/legacy/Wicked.hbm.xml	2006-10-30 15:46:48 UTC (rev 10658)
+++ trunk/Hibernate3/test/org/hibernate/test/legacy/Wicked.hbm.xml	2006-10-30 16:19:10 UTC (rev 10659)
@@ -32,6 +32,7 @@
         <many-to-one name="objectManyToOne"  class="org.hibernate.test.legacy.Employee" column="MANAGER_ID"/>
 		<component name="component" class="net.sf.hibern8ide.test.MonetaryAmount">
 		  <meta attribute="componentonly" inherit="true"/>
+		  <meta attribute="implements">AnotherInterface</meta>
 		  <meta attribute="allcomponent"/>
  		  <meta attribute="globalmutated">monetaryamount level</meta>
 			<property name="x" type="string">




More information about the hibernate-commits mailing list