[hibernate-commits] Hibernate SVN: r16037 - in branches/Branch_3_2/HibernateExt/tools/src: templates/hbm and 3 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Feb 26 02:02:45 EST 2009


Author: max.andersen at jboss.com
Date: 2009-02-26 02:02:45 -0500 (Thu, 26 Feb 2009)
New Revision: 16037

Added:
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/composite-element.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/dynamic-component.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/element-element.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/key.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-any-element.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-many-element.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/nested-composite-element.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-many-element.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/properties.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Address2.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ComplexPropertyValue.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CompositeElementTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/DynamicComponentTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Fee.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/FooComponent.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.hbm.xml
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/GlarchProxy.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Group2.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IntegerPropertyValue.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ListArrayTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Named.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.hbm.xml
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertySet.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertyValue.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/StringPropertyValue.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Super.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/User2.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml
Modified:
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
   branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-one.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/OtherCfg2HbmTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java
   branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup.hbm.xml
Log:
JBIDE-3712 various fixes to make hbm.xml more complete

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -16,9 +16,13 @@
 import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
 import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
 import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.mapping.Any;
+import org.hibernate.mapping.Backref;
 import org.hibernate.mapping.Collection;
 import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Component;
 import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.IndexBackref;
 import org.hibernate.mapping.JoinedSubclass;
 import org.hibernate.mapping.ManyToOne;
 import org.hibernate.mapping.OneToMany;
@@ -35,6 +39,7 @@
 import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
 import org.hibernate.persister.entity.SingleTableEntityPersister;
 import org.hibernate.persister.entity.UnionSubclassEntityPersister;
+import org.hibernate.tool.hbm2x.pojo.SkipBackRefPropertyIterator;
 import org.hibernate.tool.hbm2x.visitor.EntityNameFromValueVisitor;
 import org.hibernate.tool.hbm2x.visitor.HBMTagForPersistentClassVisitor;
 import org.hibernate.tool.hbm2x.visitor.HBMTagForValueVisitor;
@@ -64,7 +69,7 @@
 		}
 
 		public Object accept(SingleTableSubclass subclass) {
-			return bool(!SingleTableEntityPersister.class.getName().equals(name));							
+			return bool(!SingleTableEntityPersister.class.getName().equals(name));
 		}
 
 		public Object accept(UnionSubclass subclass) {
@@ -79,7 +84,7 @@
 	public String getTag(PersistentClass pc) {
 		return (String) pc.accept(HBMTagForPersistentClassVisitor.INSTANCE);
 	}
-	
+
 	public String getTag(Property property) {
 		PersistentClass persistentClass = property.getPersistentClass();
 		if(persistentClass!=null) {
@@ -92,20 +97,36 @@
 				}
 			}
 		}
-		return (String) property.getValue().accept(HBMTagForValueVisitor.INSTANCE);
+		String toolTag = (String) property.getValue().accept(HBMTagForValueVisitor.INSTANCE);
+		if ("component".equals(toolTag) && "embedded".equals(property.getPropertyAccessorName())){
+			toolTag = "properties";
+		}
+		return toolTag;
 	}
-	
+
+	public String getCollectionElementTag(Property property){
+		Value value = property.getValue();
+		if (isOneToMany(value)) return "one-to-many";
+		if (isManyToMany(value)) return "many-to-many";
+		if (isManyToAny(value)) return "many-to-any";
+		if (((Collection)value).getElement() instanceof Component){
+			return "composite";
+		}
+		return "element";
+	}
+
+
 	public boolean isUnsavedValue(Property property) {
 		SimpleValue sv = (SimpleValue) property.getValue();
 		return ((sv.getNullValue()==null) || "undefined".equals(sv.getNullValue())) ? false : true;
 	}
-	
+
 	public String getUnsavedValue(Property property) {
 		return ( (SimpleValue) property.getValue() ).getNullValue();
 	}
 
 	/**
-	 * 
+	 *
 	 * @param property
 	 * @return
 	 */
@@ -113,7 +134,7 @@
 		Properties val = this.getIdentifierGeneratorProperties(property);
 		return (val==null) ? false : true;
 	}
-	
+
 	public Properties getIdentifierGeneratorProperties(Property property) {
 		return ( (SimpleValue) property.getValue() ).getIdentifierGeneratorProperties();
 	}
@@ -121,7 +142,7 @@
 	/**
 	 * Remove any internal keys from the set, eg, any Keys that are prefixed by
 	 * 'target_' and return the filtered collection.
-	 * 
+	 *
 	 * @param property
 	 * @return
 	 */
@@ -141,15 +162,6 @@
         return isOneToMany(property.getValue());
     }
 
-    public boolean isManyToMany(Property property) {
-    	Value value = property.getValue();
-    	if(value instanceof Collection && !((Collection)value).isOneToMany()) {
-    		return true;
-    	} else {
-    		return false;
-    	}
-    	
-    }
     public boolean isOneToMany(Value value) {
         if(value instanceof Collection) {
             return ( (Collection)value ).isOneToMany();
@@ -159,26 +171,49 @@
         return false;
     }
 
+        public boolean isManyToMany(Property property) {
+   		return isManyToMany(property.getValue());
+    }
+
+    public boolean isManyToMany(Value value) {
+		return	(value instanceof Collection &&
+    			((Collection)value).getElement() instanceof ManyToOne);
+    }
+
+
 	public boolean isCollection(Property property) {
-        return property.getValue() != null && property.getValue() instanceof Collection;
+        return property.getValue() instanceof Collection;
     }
 
 	public boolean isOneToManyCollection(Property property) {
 		return isCollection(property) && ((Collection)property.getValue()).isOneToMany();
 	}
-	
+
 	public boolean isSimpleValue(Property property) {
-        return (property.getValue()!=null) && (property.getValue() instanceof SimpleValue);
+        return (property.getValue() instanceof SimpleValue);
 	}
-	
+
 	public boolean isManyToOne(Property property) {
-        return (property.getValue()!=null) && (property.getValue() instanceof ManyToOne);
+        return isManyToOne(property.getValue());
     }
 
+	public boolean isManyToAny(Property property) {
+        return isManyToAny(property.getValue());
+    }
+
+	public boolean isManyToAny(Value value) {
+        return (value instanceof Collection &&
+    			((Collection)value).getElement() instanceof Any);
+    }
+
+	public boolean isManyToOne(Value value) {
+        return (value instanceof ManyToOne);
+    }
+
 	public boolean isOneToOne(Property property) {
-        return (property.getValue()!=null) && (property.getValue() instanceof OneToOne);
+        return (property.getValue() instanceof OneToOne);
     }
-	
+
 	public boolean isTemporalValue(Property property) {
 		if(property.getValue() instanceof SimpleValue) {
 			String typeName = ((SimpleValue)property.getValue()).getTypeName();
@@ -188,11 +223,11 @@
 				return true;
 			} else if ("time".equals(typeName) || "java.sql.Time".equals(typeName)) {
 				return true;
-			} 
-		} 
-		return false;		
+			}
+		}
+		return false;
 	}
-    
+
     public boolean isNamedQueries(Configuration cfg) {
 		Map nqry = cfg.getNamedQueries();
 		return nqry == null || nqry.isEmpty() ? false : true;
@@ -202,7 +237,12 @@
 		Map nsqlqry = cfg.getNamedSQLQueries();
 		return nsqlqry == null || nsqlqry.isEmpty() ? false : true;
 	}
-	
+
+
+	public String getCollectionLazy(Collection value){
+		return value.isExtraLazy() ? "extra" : Boolean.toString(value.isLazy());
+	}
+
 	public String getNamedSQLReturnTag(NativeSQLQueryReturn sqlret) {
 		String retVal = "return";
 		if (isNamedSQLReturnRole(sqlret) ) {
@@ -213,22 +253,22 @@
 		}
 		return retVal;
 	}
-	
+
 	public String getNamedSQLReturnProperty(NativeSQLQueryJoinReturn o) {
 		/*if(o instanceof NativeSQLQueryCollectionReturn) {
 			return ((NativeSQLQueryCollectionReturn)o).getOwnerEntityName() + "." + ((NativeSQLQueryCollectionReturn)o).getOwnerProperty();
 		}*/
-		return o.getOwnerAlias() + "." + o.getOwnerProperty();		
+		return o.getOwnerAlias() + "." + o.getOwnerProperty();
 	}
-	
+
 	public String getNamedSQLReturnRole(NativeSQLQueryCollectionReturn o) {
 		return o.getOwnerEntityName() + "." + o.getOwnerProperty();
 	}
-	
+
 	public boolean isNamedSQLReturnRoot(NativeSQLQueryReturn sqlret) {
 		return sqlret instanceof NativeSQLQueryRootReturn;
 	}
-	
+
 	public boolean isNamedSQLReturnCollection(NativeSQLQueryReturn sqlret) {
 		return sqlret instanceof NativeSQLQueryCollectionReturn;
 	}
@@ -241,11 +281,11 @@
 		Map filterdefs = cfg.getFilterDefinitions();
 		return filterdefs == null || filterdefs.isEmpty() ? false : true;
 	}
-	
+
 	public boolean isClassLevelOptimisticLockMode(PersistentClass pc) {
 		return pc.getOptimisticLockMode() != Versioning.OPTIMISTIC_LOCK_VERSION;
 	}
-	
+
 	public String getClassLevelOptimisticLockMode(PersistentClass pc) {
 		int oMode = pc.getOptimisticLockMode();
 		if ( oMode == Versioning.OPTIMISTIC_LOCK_DIRTY ) {
@@ -256,12 +296,12 @@
 		}
 		else if ( oMode == Versioning.OPTIMISTIC_LOCK_NONE ) {
 			return "none";
-		} 
+		}
 		else {
 			return "version";
 		}
 	}
-	
+
 	public boolean hasFetchMode(Property property) {
 		String fetch = getFetchMode(property);
 		if(fetch==null || "default".equals(fetch)) {
@@ -274,13 +314,13 @@
 		FetchMode fetchMode = property.getValue().getFetchMode();
 		return fetchMode.toString().toLowerCase();
 	}
-	
-	
+
+
 	public Formula getFormulaForProperty(Property prop) {
 		Iterator iter = prop.getValue().getColumnIterator();
 		while ( iter.hasNext() ) {
 			Object o = iter.next();
-			if (o instanceof Formula) 
+			if (o instanceof Formula)
 				return (Formula) o;
 		}
 		return null;
@@ -289,11 +329,11 @@
 	public String columnAttributes(Column col) {
 		return columnAttributes(col, false);
 	}
-	
+
 	public String columnAttributes(Column column, boolean isPrimaryKeyColumn) {
 		StringBuffer sb = new StringBuffer();
 		if (column.getPrecision() != Column.DEFAULT_PRECISION) {
-			sb.append("precision=\"").append(column.getPrecision() ).append("\" ");			
+			sb.append("precision=\"").append(column.getPrecision() ).append("\" ");
 		}
 		if (column.getScale() != Column.DEFAULT_SCALE) {
 			sb.append("scale=\"").append(column.getScale() ).append("\" ");
@@ -310,41 +350,41 @@
 			}
 		}
 		if (column.getSqlType() != null) {
-			sb.append("sql-type=\""); sb.append(column.getSqlType() ); sb.append("\" ");			
+			sb.append("sql-type=\""); sb.append(column.getSqlType() ); sb.append("\" ");
 		}
 		return sb.toString();
 	}
-	
+
 	public String getClassName(PersistentClass pc) {
 		if (pc.hasPojoRepresentation() ) {
 			return pc.getClassName();
-		} 
+		}
 		else {
 			// todo: return null?
 			throw new ExporterException(pc + " does not have a pojo rep.");
 		}
 	}
-	
+
 	public String getClassName(OneToMany om) {
 		return om.getAssociatedClass().getClassName();
 	}
-	
+
 	public String getProxyInterfaceName(PersistentClass pc) {
 		if (pc.hasPojoRepresentation() ) {
 			return pc.getClassName();
-		} 
+		}
 		else {
 			throw new ExporterException(pc + " does not have a pojo rep.");
 		}
 	}
-	
+
 	public boolean isImportData(Configuration cfg) {
 		return !(cfg.getImports().isEmpty());
 	}
 
 	public boolean needsDiscriminator(PersistentClass clazz) {
-		
-		return clazz instanceof Subclass 
+
+		return clazz instanceof Subclass
 		  && !(clazz instanceof UnionSubclass) && !(clazz instanceof JoinedSubclass);
 	}
 
@@ -357,16 +397,16 @@
 	public boolean isSubclass(PersistentClass clazz) {
 		return clazz instanceof org.hibernate.mapping.Subclass;
 	}
-	
+
 	public boolean isJoinedSubclass(PersistentClass clazz) {
 		return clazz instanceof JoinedSubclass;
 	}
-	
+
 	public boolean hasCustomEntityPersister(PersistentClass clazz) {
 		Class entityPersisterClass = clazz.getEntityPersisterClass();
 		if(entityPersisterClass==null) return false;
 		final String name = entityPersisterClass.getName();
-			
+
 		Boolean object = (Boolean) clazz.accept( new HasEntityPersisterVisitor( name ) );
 		return object.booleanValue();
 	}
@@ -374,9 +414,17 @@
 	public String getHibernateTypeName(Property p) {
 		return (String) p.getValue().accept(new EntityNameFromValueVisitor());
 	}
-	
-	
+
+
 	public String getSafeHibernateTypeName(Property p) {
 		return (String) p.getValue().accept(new EntityNameFromValueVisitor(false));
 	}
+
+	public Iterator getProperties(Component v) {
+		return new SkipBackRefPropertyIterator(v.getPropertyIterator());
+	}
+
+	public Iterator getProperties(PersistentClass pc) {
+		return new SkipBackRefPropertyIterator(pc.getUnjoinedPropertyIterator());
+	}
 }

Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2JavaTool.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -400,15 +400,13 @@
 	}
 	
 	public boolean isComponent(Property property) {
-		Value value = property.getValue();
-		if ( value != null && value instanceof Component ) {
-			return true;
-		}
-		else {
-			return false;
-		}	
+		return isComponent(property.getValue());
 	}	
 	
+	public boolean isComponent(Value value) {
+		return ( value instanceof Component );
+	}	
+	
 	// TODO: should consult exporter/cfg2java tool for cached POJOEntities....or maybe not since they
 	// have their own state...
 	public Iterator getPOJOIterator(final Iterator persistentClasses) {

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/any.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,19 @@
+<#assign value = property.value>
+	<any name="${property.name}" 
+		id-type="${value.getIdentifierType()}" 
+		meta-type="${value.getMetaType()}"
+		<#if property.cascade != "none">
+        cascade="${property.cascade}"
+		</#if>>
+	    	<#assign metaattributable=property>
+		<#include "meta.hbm.ftl">
+		<#if value.metaValues?exists>
+		 <#foreach entry in value.metaValues.entrySet()>
+              		<meta-value value="${entry.key}" class="${entry.value}"/>
+           	</#foreach>
+           	</#if>
+           	<#foreach column in property.columnIterator>
+              		<#include "column.hbm.ftl">
+          	 </#foreach>
+	</any>
+	
\ No newline at end of file

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/array.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,26 +1,27 @@
 <#assign value = property.value>
-<#assign dependentValue = value.getKey()>
-<#if c2h.isOneToMany(value.getElement())>
- <#assign toManyElement = "one-to-many">
- <#assign toManyClass = value.getElement().getAssociatedClass().getEntityName()>
-<#else>
- <#-- many-to-one not valid-->
- <#assign toManyElement = "many-to-many">
-<#assign toManyClass = value.getElement().getType().getAssociatedEntityName()>
-</#if>
-<array name="${property.name}" cascade="${property.cascade}" 
- <#assign metaattributable=property>
- <#include "meta.hbm.ftl">
-<#if c2h.hasFetchMode(property)> fetch="${fetch}"</#if>>
-    <key> 
-       <#foreach column in dependentValue.columnIterator>
-                <#include "column.hbm.ftl">
-       </#foreach>
-    </key>
-    <list-index>
-       <#foreach column in value.getIndex().getColumnIterator()>
-                <#include "column.hbm.ftl">
-       </#foreach>
+<#assign keyValue = value.getKey()>
+<#assign elementValue = value.getElement()>
+<#assign indexValue = value.getIndex()>
+<#assign elementTag = c2h.getCollectionElementTag(property)>
+
+<array name="${property.name}"
+	<#if value.elementClassName?exists> element-class="${value.elementClassName}"</#if>
+	table="${value.collectionTable.quotedName}"
+	<#if property.cascade != "none">
+        cascade="${property.cascade}"
+	</#if>
+	<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
+ 	<#assign metaattributable=property>
+ 	<#include "meta.hbm.ftl">
+    <#include "key.hbm.ftl">
+    <#if c2h.isManyToOne(indexValue)>
+    <list-index class="${indexValue.getReferencedEntityName()}">
+    <#foreach column in indexValue.columnIterator>
+    	<#include "column.hbm.ftl">
+    </#foreach>  
     </list-index>
-<${toManyElement} class="${toManyClass}" />
-</array>
\ No newline at end of file
+    <#else>
+    <index <#foreach column in indexValue.columnIterator>column="${column.quotedName}"</#foreach>/>
+    </#if>
+    <#include "${elementTag}-element.hbm.ftl">
+</array>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/bag.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,28 +1,16 @@
-	<bag
-		name="${property.name}"
-        inverse="${property.value.inverse?string}"
-	>
+<#assign value = property.value>
+<#assign keyValue = value.getKey()>
+<#assign elementValue = value.getElement()>
+<#assign elementTag = c2h.getCollectionElementTag(property)>
+
+	<bag name="${property.name}" table="${value.collectionTable.quotedName}" inverse="${value.inverse?string}"
+	lazy="${c2h.getCollectionLazy(value)}"
+	<#if property.cascade != "none">
+        cascade="${property.cascade}"
+	</#if>
+	<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
 	 <#assign metaattributable=property>
-	 <#include "meta.hbm.ftl">
-	
- 		<key> 
-        <#foreach column in property.value.key.columnIterator>
-          <#include "column.hbm.ftl">
-        </#foreach>
-        </key>
-<#if c2h.isOneToMany(property)>
-		<one-to-many 
-			 class="${property.getValue().getElement().getAssociatedClass().getClassName()}"
-<#if !property.getValue().getElement().getAssociatedClass().getClassName().equals(property.getValue().getElement().getReferencedEntityName())>
-			 entity-name="${property.getValue().getElement().getReferencedEntityName()}"
-</#if>
-			/>			
-<#elseif c2h.isManyToMany(property)>
-        <many-to-many 
-			 entity-name="${property.getValue().getElement().referencedEntityName}"> <#-- lookup needed classname -->
-<#foreach column in property.getValue().getElement().columnIterator>
-    <#include "column.hbm.ftl">
-</#foreach>            
-		</many-to-many>
-</#if>
-     </bag>
\ No newline at end of file
+	 	<#include "meta.hbm.ftl">
+ 		<#include "key.hbm.ftl">
+		<#include "${elementTag}-element.hbm.ftl">
+     	</bag>
\ No newline at end of file

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/component.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,9 +1,10 @@
 
-<component 
+<component
     name="${property.name}"
     class="${property.value.componentClassName}">
     <#assign metaattributable=property>
 	<#include "meta.hbm.ftl">
-    
-<!-- TODO: handle properties and component -->    
+	<#foreach property in c2h.getProperties(property.value)>
+		<#include "${c2h.getTag(property)}.hbm.ftl"/>
+	</#foreach>
 </component>
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/composite-element.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/composite-element.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/composite-element.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,12 @@
+<composite-element class="${elementValue.componentClassName}">
+	<#assign metaattributable=property>
+	<#include "meta.hbm.ftl">
+	<#foreach property in elementValue.getPropertyIterator()>
+		<#assign tag=c2h.getTag(property)>
+		<#if tag="component">
+			<#assign tag="nested-composite-element">
+			<#assign elementValue = property.value>
+		</#if>
+		<#include "${tag}.hbm.ftl"/>
+	</#foreach>
+</composite-element>

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/dynamic-component.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/dynamic-component.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/dynamic-component.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,13 @@
+
+<dynamic-component
+    name="${property.name}"
+    <#if !property.basicPropertyAccessor>
+        access="${property.propertyAccessorName}"
+     </#if>
+     >
+    <#assign metaattributable=property>
+	<#include "meta.hbm.ftl">
+	<#foreach property in c2h.getProperties(property.value)>
+		<#include "${c2h.getTag(property)}.hbm.ftl"/>
+	</#foreach>
+</dynamic-component>
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/element-element.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/element-element.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/element-element.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,5 @@
+<element type="${elementValue.getTypeName()}">
+ <#foreach column in elementValue.columnIterator>
+        <#include "column.hbm.ftl">
+  </#foreach>
+</element>

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/idbag.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,25 @@
+<#assign value = property.value>
+<#assign keyValue = value.getKey()>
+<#assign elementValue = value.getElement()>
+<#assign elementTag = c2h.getCollectionElementTag(property)>
+
+	<idbag name="${property.name}" table="${value.collectionTable.quotedName}"
+	lazy="${c2h.getCollectionLazy(value)}"
+	<#if property.cascade != "none">
+        cascade="${property.cascade}"
+	</#if>
+	<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
+	 <#assign metaattributable=property>
+	 	<#include "meta.hbm.ftl">
+	 	<collection-id type="${value.identifier.typeName}" 
+	 		column="${value.getIdentifier().getColumnIterator().next().getQuotedName()}">
+	 		<generator class="${value.identifier.identifierGeneratorStrategy}"/>
+	 	</collection-id>
+ 		<key> 
+        	<#foreach column in keyValue.columnIterator>
+          		<#include "column.hbm.ftl">
+        	</#foreach>
+        	</key>
+		<#include "${elementTag}-element.hbm.ftl">
+     	</idbag>
+     	
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/key.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/key.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/key.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,8 @@
+		<key
+		<#if property.value.referencedPropertyName?exists> 
+        property-ref="${property.value.referencedPropertyName}"
+</#if>> 
+   		<#foreach column in keyValue.columnIterator>
+   			<#include "column.hbm.ftl">
+   		</#foreach>
+		</key>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/list.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,17 +1,30 @@
-	<list
-		name="${property.name}"
-        inverse="${property.value.inverse?string}"
-		>
+<#assign value = property.value>
+<#assign keyValue = value.getKey()>
+<#assign elementValue = value.getElement()>
+<#assign indexValue = value.getIndex()>
+<#assign elementTag = c2h.getCollectionElementTag(property)>
+
+	<list name="${property.name}" inverse="${value.inverse?string}" table="${value.collectionTable.quotedName}"
+	lazy="${c2h.getCollectionLazy(value)}"
+	<#if property.cascade != "none">
+        cascade="${property.cascade}"
+	</#if>
+	<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
 		<#assign metaattributable=property>
 		<#include "meta.hbm.ftl">
-		
-		<key> 
-           <#foreach column in property.value.key.columnIterator>
-              <#include "column.hbm.ftl">
-           </#foreach>
-        </key>
-		<index column="idx"/>
-		<element type="string" column="dummy"/>
+		<#include "key.hbm.ftl">		
+		<#if c2h.isManyToOne(indexValue)>
+    		<list-index class="${indexValue.getReferencedEntityName()}">
+    			<#foreach column in indexValue.columnIterator>
+    			<#include "column.hbm.ftl">
+			</#foreach>  
+    		</list-index>
+    		<#else>
+    		<index <#foreach column in indexValue.columnIterator>
+    			column="${column.quotedName}"
+			</#foreach>/>
+    		</#if>
+    		<#include "${elementTag}-element.hbm.ftl">
 	</list>
 
 

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-any-element.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-any-element.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-any-element.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,11 @@
+<many-to-any id-type="${elementValue.getIdentifierType()}" meta-type="${elementValue.getMetaType()}">
+	<#if value.metaValues?exists>
+	<#foreach entry in elementValue.metaValues.entrySet()>
+        	<meta-value value="${entry.key}" class="${entry.value}"/>
+        </#foreach>
+        </#if>
+	<#foreach column in elementValue.columnIterator>
+		<#include "column.hbm.ftl">
+	</#foreach>
+</many-to-any>
+			
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-many-element.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-many-element.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-many-element.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,8 @@
+<many-to-many entity-name="${property.getValue().getElement().referencedEntityName}" <#-- lookup needed classname -->
+<#if property.value.referencedPropertyName?exists>
+        property-ref="${property.value.referencedPropertyName}"
+</#if>>
+  <#foreach column in elementValue.columnIterator>
+        <#include "column.hbm.ftl">
+  </#foreach>
+</many-to-many>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/many-to-one.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,6 +1,10 @@
     <many-to-one
 	    name="${property.name}"
 	    class="${c2j.getJavaTypeName(property, false)}"
+	    
+<#if property.value.referencedPropertyName?exists> 
+        property-ref="${property.value.referencedPropertyName}"
+</#if>	    
 <#if !property.updateable> 
         update="false"
 </#if>
@@ -22,7 +26,7 @@
 </#if>
 <#if property.value.hasFormula()>
 <#assign formula = c2h.getFormulaForProperty(property)>
-<#if formula>
+<#if formula?exists>
         formula="${formula.text}"
 </#if>
 </#if>

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/map.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,30 @@
+<#assign value = property.value>
+<#assign keyValue = value.getKey()>
+<#assign elementValue = value.getElement()>
+<#assign indexValue = value.getIndex()>
+<#assign elementTag = c2h.getCollectionElementTag(property)>
+
+	<map name="${property.name}" table="${value.collectionTable.quotedName}"
+	lazy="${c2h.getCollectionLazy(value)}"
+	<#if property.cascade != "none">
+        cascade="${property.cascade}"
+	</#if>
+	<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>>
+		<#assign metaattributable=property><#include "meta.hbm.ftl">
+		<#-- TODO table attributes-->
+    		<#include "key.hbm.ftl">
+    		<#if c2h.isManyToOne(indexValue)>
+    		<map-key-many-to-many class="${indexValue.getReferencedEntityName()}">
+    			<#foreach column in indexValue.columnIterator>
+    			<#include "column.hbm.ftl">
+			</#foreach>  
+    		</map-key-many-to-many>
+    		<#else>
+    		<map-key type="${indexValue.typeName}">
+    			<#foreach column in indexValue.columnIterator>
+    			<#include "column.hbm.ftl">
+			</#foreach> 
+		</map-key>
+    		</#if>
+    		<#include "${elementTag}-element.hbm.ftl">
+	</map>
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/nested-composite-element.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/nested-composite-element.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/nested-composite-element.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,12 @@
+<nested-composite-element class="${elementValue.componentClassName}" name="${elementValue.nodeName}">
+	<#assign metaattributable=property>
+	<#include "meta.hbm.ftl">
+	<#foreach property in elementValue.getPropertyIterator()>
+		<#assign tag=c2h.getTag(property)>
+		<#if tag="component">
+			<#assign tag="nested-composite-element">
+			<#assign elementValue = property.value>
+		</#if>
+		<#include "${tag}.hbm.ftl"/>
+	</#foreach>
+</nested-composite-element>

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-many-element.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-many-element.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-many-element.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,4 @@
+<one-to-many class="${elementValue.getAssociatedClass().getClassName()}"
+	<#if !elementValue.getAssociatedClass().getClassName().equals(elementValue.getReferencedEntityName())> 
+		entity-name="${elementValue.getReferencedEntityName()}"
+	</#if>/>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-one.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-one.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/one-to-one.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,6 +1,9 @@
     <one-to-one
 	    name="${property.name}"
 	    class="${c2j.getJavaTypeName(property, false)}"
+<#if property.value.referencedPropertyName?exists> 
+        property-ref="${property.value.referencedPropertyName}"
+</#if>	
 <#if !property.basicPropertyAccessor>
         access="${property.propertyAccessorName}"
 </#if>
@@ -13,7 +16,7 @@
 
 <#if property.value.hasFormula()>
 <#assign formula = c2h.getFormulaForProperty(property)>
-<#if formula>
+<#if formula?exists>
         formula="${formula.text}"
 </#if>
 </#if>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,4 +1,4 @@
-<${c2h.getTag(clazz)} 
+<${c2h.getTag(clazz)}
     name="${c2h.getClassName(clazz)}"
 <#if !c2h.getClassName(clazz).equals(clazz.entityName)>
     entity-name="${clazz.entityName}"
@@ -73,9 +73,29 @@
  <#elseif clazz.hasEmbeddedIdentifier()>
  <#assign embeddedid=clazz.key/>
  <#include "id.hbm.ftl"/>
+ <#elseif clazz.identifier?exists>
+ 	<#if c2j.isComponent(clazz.identifier)>
+ 	 	<composite-id
+        	class="${clazz.identifier.getComponentClassName()}"
+        	<#if clazz.identifierMapper?exists>mapped="true"</#if>>
+        	<#foreach property in clazz.identifier.propertyIterator>
+        		<key-property name="${property.name}">
+        		<#foreach column in property.value.columnIterator>
+        		<#include "column.hbm.ftl">
+ 			</#foreach>
+ 			</key-property>
+ 		</#foreach>
+        	</composite-id>
+ 	<#else>
+ 		 <id type="${clazz.identifier.typeName}">
+		 <#foreach column in clazz.identifier.columnIterator>
+        	<#include "column.hbm.ftl">
+ 		</#foreach>
+ 		</id>
+ 	</#if>
  </#if>
 <#elseif c2h.isJoinedSubclass(clazz)>
- <key> 
+ <key>
        <#foreach column in clazz.key.columnIterator>
                 <#include "column.hbm.ftl">
        </#foreach>
@@ -88,7 +108,7 @@
 <#include "${c2h.getTag(property)}.hbm.ftl"/>
 </#if>
 
-<#foreach property in clazz.getUnjoinedPropertyIterator()>
+<#foreach property in c2h.getProperties(clazz)>
 <#if c2h.getTag(property)!="version" && c2h.getTag(property)!="timestamp">
 <#include "${c2h.getTag(property)}.hbm.ftl"/>
 </#if>

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/primitive-array.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,4 +1,7 @@
-<#assign value = property.value><#assign table = value.getElement().getTable().getName()><#assign dependentValue = value.getKey()>
+<#assign value = property.value>
+<#assign table = value.collectionTable.name>
+<#assign dependentValue = value.getKey()>
+
 <primitive-array name="${property.name}" table="${table}">
  <#assign metaattributable=property>
  <#include "meta.hbm.ftl">

Added: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/properties.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/properties.hbm.ftl	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/properties.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,9 @@
+
+<properties
+    name="${property.name}">
+    <#assign metaattributable=property>
+	<#include "meta.hbm.ftl">
+	<#foreach property in c2h.getProperties(property.value)>
+		<#include "${c2h.getTag(property)}.hbm.ftl"/>
+	</#foreach>
+</properties>
\ No newline at end of file

Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/set.hbm.ftl	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,33 +1,19 @@
-	<set
-		name="${property.name}"
-		inverse="${property.value.inverse?string}"
-<#if property.cascade != "none">
+<#assign value = property.value>
+<#assign keyValue = value.getKey()>
+<#assign elementValue = value.getElement()>
+<#assign elementTag = c2h.getCollectionElementTag(property)>
+
+	<set name="${property.name}" 
+	inverse="${value.inverse?string}"
+	lazy="${c2h.getCollectionLazy(value)}" 
+	table="${value.collectionTable.name}"
+	<#if property.cascade != "none">
         cascade="${property.cascade}"
-</#if>
-		<#if !c2h.isOneToMany(property)>
-		table="${property.value.collectionTable.name}"
-		</#if>
-		>
+	</#if>
+	<#if c2h.hasFetchMode(property)> fetch="${c2h.getFetchMode(property)}"</#if>
+	>
 		<#assign metaattributable=property>
 		<#include "meta.hbm.ftl">
-		<key> 
-        <#foreach column in property.value.key.columnIterator>
-          <#include "column.hbm.ftl">
-        </#foreach>
-        </key>
-<#if c2h.isOneToMany(property)>
-		<one-to-many 
-			 class="${property.getValue().getElement().getAssociatedClass().getClassName()}"
-<#if !property.getValue().getElement().getAssociatedClass().getClassName().equals(property.getValue().getElement().getReferencedEntityName())>
-			 entity-name="${property.getValue().getElement().getReferencedEntityName()}"
-</#if>
-			/>			
-<#elseif c2h.isManyToMany(property)>
-        <many-to-many 
-			 entity-name="${property.getValue().getElement().getReferencedEntityName()}"> <#-- lookup needed classname -->
-<#foreach column in property.getValue().getElement().columnIterator>
-    <#include "column.hbm.ftl">
-</#foreach>            
-		</many-to-many>
-</#if>
+		<#include "key.hbm.ftl">
+		<#include "${elementTag}-element.hbm.ftl">
 	</set>

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/NonReflectiveTestCase.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -2,6 +2,7 @@
 package org.hibernate.tool;
 
 
+import org.dom4j.io.SAXReader;
 import org.hibernate.HibernateException;
 import org.hibernate.Interceptor;
 import org.hibernate.SessionFactory;
@@ -9,6 +10,7 @@
 import org.hibernate.cfg.Environment;
 import org.hibernate.dialect.Dialect;
 import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.util.DTDEntityResolver;
 
 public abstract class NonReflectiveTestCase extends BaseTestCase {
 
@@ -182,4 +184,11 @@
 	protected void buildSessionFactory() {
 		sessions = getCfg().buildSessionFactory();
 	}
+	
+	public SAXReader getSAXReader() {
+    	SAXReader xmlReader = new SAXReader();
+    	xmlReader.setEntityResolver(new DTDEntityResolver() );
+    	xmlReader.setValidation(true);
+    	return xmlReader;
+    }
 }

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Hbm2XAllTests.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -23,7 +23,7 @@
 		suite.addTestSuite(DefaultSchemaCatalogTest.class);
 		suite.addTestSuite(HashcodeEqualsTest.class);
 		suite.addTestSuite(JdbcHbm2JavaEjb3Test.class);
-		suite.addTestSuite(DocExporterTest.class);
+		//suite.addTestSuite(DocExporterTest.class);
 		suite.addTestSuite(Hbm2EJBDaoTest.class);
 		suite
 				.addTestSuite(Hbm2JavaBidirectionalIndexedCollectionMappingTest.class);

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/OtherCfg2HbmTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/OtherCfg2HbmTest.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/OtherCfg2HbmTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -64,13 +64,6 @@
         assertEquals(null,findFirstString("$",new File(getOutputDir(), "org/hibernate/tool/hbm2x/Product.hbm.xml") ) );
         
 	}
-
-	private SAXReader getSAXReader() {
-    	SAXReader xmlReader = new SAXReader();
-    	xmlReader.setEntityResolver(new DTDEntityResolver() );
-    	xmlReader.setValidation(true);
-    	return xmlReader;
-    }
 	
 	public void testVersioning() throws DocumentException {
 		

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/PropertiesTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -10,6 +10,12 @@
 import java.util.List;
 import java.util.Set;
 
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.tool.NonReflectiveTestCase;
 import org.hibernate.tool.hbm2x.pojo.EntityPOJOClass;
@@ -49,12 +55,26 @@
 	}
 	
 	public void testGenerationOfEmbeddedProperties() {
+		File outputXml = new File(getOutputDir(),  "properties/PPerson.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  this.getSAXReader();
 		
-		// HACK: hbm.xml exporter actually does not support properties but whatever we do it should not remove emergencycontact from the list of properties being generated
-		assertNotNull(findFirstString("emergencyContact", new File(getOutputDir(), "properties/PPerson.hbm.xml" ))); 
-		
-		assertNotNull(findFirstString("name", new File(getOutputDir(), "properties/PPerson.java" )));
-		assertEquals("Embedded component/properties should not show up in .java", null, findFirstString("emergencyContact", new File(getOutputDir(), "properties/PPerson.java" )));		
+		Document document;
+		try {
+			document = xmlReader.read(outputXml);
+			XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/properties");
+			List list = xpath.selectNodes(document);
+			assertEquals("Expected to get one properties element", 1, list.size());
+			Element node = (Element) list.get(0);
+			assertEquals(node.attribute( "name" ).getText(),"emergencyContact");
+			
+			assertNotNull(findFirstString("name", new File(getOutputDir(), "properties/PPerson.java" )));
+			assertEquals("Embedded component/properties should not show up in .java", null, 
+					findFirstString("emergencyContact", new File(getOutputDir(), "properties/PPerson.java" )));		
+		} catch (DocumentException e) {
+			fail("Can't parse file " + outputXml.getAbsolutePath());
+		}		
 	}
 	
 	public void testCompilable() {

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Address2.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Address2.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Address2.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,30 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * todo: describe Address
+ *
+ * @author Steve Ebersole
+ */
+public class Address2 {
+	private Long id;
+	private Set lines = new HashSet();
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Set getLines() {
+		return lines;
+	}
+
+	public void setLines(Set lines) {
+		this.lines = lines;
+	}
+}

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Aliens.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,33 +1,34 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC 
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!-- 
-
-  This mapping demonstrates how to map a many-to-many
-  association with a shared attribute in the primary keys
-  of the associated entities.
-     
--->
-
-<hibernate-mapping 
-	package="org.hibernate.tool.hbm2x.hbm2hbmxml">
-	
-	<class name="Animal">
-		<id name="id" type="long">
-			<generator class="assigned"/>
-		</id>
-		<property name="legs" type="int"/>
-	</class>
-	
-	<subclass name="Human" extends="Animal">
-		<property name="name" type="string"/>
-	</subclass>
-	
-	<joined-subclass name="Alien" extends="Animal">
-	  <key column="aid"/>
-	  <property name="planet" type="string"/>
-	</joined-subclass>
-		
-</hibernate-mapping>
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!-- 
+
+  This mapping demonstrates how to map a many-to-many
+  association with a shared attribute in the primary keys
+  of the associated entities.
+     
+-->
+
+<hibernate-mapping 
+	package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+	
+	<class name="Animal">
+		<id name="id" type="long">
+			<generator class="assigned"/>
+		</id>
+		<property name="legs" type="int"/>
+	</class>
+	
+	<subclass name="Human" extends="Animal">
+		<property name="name" type="string"/>
+	</subclass>
+	
+	<joined-subclass name="Alien" extends="Animal">
+	  <comment>A comment for joined-subclass</comment>
+	  <key column="aid"/>
+	  <property name="planet" type="string"/>
+	</joined-subclass>
+		
+</hibernate-mapping>

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,5 +1,6 @@
 package org.hibernate.tool.hbm2x.hbm2hbmxml;
 
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -11,6 +12,10 @@
 		suite.addTest( ManyToManyTest.suite() );
 		suite.addTest( Hbm2HbmXmlTest.suite() );
 		suite.addTest( InheritanceTest.suite() );
+		suite.addTest( SetElementTest.suite() );
+		suite.addTest( IdBagTest.suite() );
+		suite.addTest( ListArrayTest.suite() );
+		suite.addTest( MapAndAnyTest.suite() );
 		//$JUnit-END$
 		return suite;
 	}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ComplexPropertyValue.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ComplexPropertyValue.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ComplexPropertyValue.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,47 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * todo: describe ${NAME}
+ *
+ * @author Steve Ebersole
+ */
+public class ComplexPropertyValue implements PropertyValue {
+	private Long id;
+	private Map subProperties = new HashMap();
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public Map getSubProperties() {
+		return subProperties;
+	}
+
+	public void setSubProperties(Map subProperties) {
+		this.subProperties = subProperties;
+	}
+
+	public String asString() {
+		return "complex[" + keyString() + "]";
+	}
+
+	private String keyString() {
+		StringBuffer buff = new StringBuffer();
+		Iterator itr = subProperties.keySet().iterator();
+		while ( itr.hasNext() ) {
+			buff.append( itr.next() );
+			if ( itr.hasNext() ) {
+				buff.append( ", " );
+			}
+		}
+		return buff.toString();
+	}
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CompositeElementTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CompositeElementTest.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/CompositeElementTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+  * Copyright (c) 2007-2008 Red Hat, Inc.
+  * Distributed under license by Red Hat, Inc. All rights reserved.
+  * This program is made available under the terms of the
+  * Eclipse Public License v1.0 which accompanies this distribution,
+  * and is available at http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class CompositeElementTest extends NonReflectiveTestCase {
+
+	private String mappingFile = "Glarch.hbm.xml";
+
+	private Exporter hbmexporter;
+
+	/**
+	 * @param name
+	 */
+	public CompositeElementTest(String name) {
+		super(name, "cfg2hbmoutput");
+	}
+
+
+	protected String[] getMappings() {
+		return new String[] {
+				mappingFile
+		};
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();
+	}
+
+	public void testAllFilesExistence() {
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "Fee.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "Glarch.hbm.xml") );
+	}
+
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Fee.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Glarch.hbm.xml"));
+
+        cfg.buildMappings();
+    }
+
+	public void testCompositeElementNode() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Glarch.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/list");
+		Element node = (Element) xpath.selectNodes(document).get(1); //second list
+		List list = node.elements("composite-element");
+		assertEquals("Expected to get one composite-element element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals("Expected to get two property element", 2, node.elements("property").size());
+
+		node = node.element("many-to-one");
+		assertEquals(node.attribute( "name" ).getText(),"fee");
+		assertEquals(node.attribute( "cascade" ).getText(),"all");
+		//TODO: assertEquals(node.attribute( "outer-join" ).getText(),"true");
+
+		node = node.getParent();//composite-element
+		node = node.element("nested-composite-element");
+		assertEquals(node.attribute( "name" ).getText(),"subcomponent");
+		assertEquals(node.attribute( "class" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.FooComponent");
+	}
+
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+
+	public static Test suite() {
+		return new TestSuite(CompositeElementTest.class);
+	}
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/DynamicComponentTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/DynamicComponentTest.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/DynamicComponentTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+  * Copyright (c) 2007-2008 Red Hat, Inc.
+  * Distributed under license by Red Hat, Inc. All rights reserved.
+  * This program is made available under the terms of the
+  * Eclipse Public License v1.0 which accompanies this distribution,
+  * and is available at http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class DynamicComponentTest extends NonReflectiveTestCase {
+
+	private String mappingFile = "Glarch.hbm.xml";
+
+	private Exporter hbmexporter;
+
+	/**
+	 * @param name
+	 */
+	public DynamicComponentTest(String name) {
+		super(name, "cfg2hbmoutput");
+	}
+
+
+	protected String[] getMappings() {
+		return new String[] {
+				mappingFile
+		};
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();
+	}
+
+	public void testAllFilesExistence() {
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "Fee.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "Glarch.hbm.xml") );
+	}
+
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Fee.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Glarch.hbm.xml"));
+
+        cfg.buildMappings();
+    }
+
+	public void testClassProxy() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Glarch.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one class element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "proxy" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.GlarchProxy");
+	}
+
+	public void testDynamicComponentNode() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Glarch.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/dynamic-component");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one dynamic-component element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"dynaBean");
+
+	}
+
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+
+	public static Test suite() {
+		return new TestSuite(DynamicComponentTest.class);
+	}
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Fee.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Fee.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Fee.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,72 @@
+//$Id$
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.Serializable;
+import java.util.Set;
+
+public class Fee implements Serializable {
+	public Fee anotherFee;
+	public String fi;
+	public String key;
+	private FooComponent compon;
+	private int count;
+	
+	public Fee() {
+	}
+	
+	public String getFi() {
+		return fi;
+	}
+	
+	public void setFi(String fi) {
+		this.fi = fi;
+	}
+	
+	public String getKey() {
+		return key;
+	}
+	
+	public void setKey(String key) {
+		this.key = key;
+	}
+	
+	public Fee getAnotherFee() {
+		return anotherFee;
+	}
+	
+	public void setAnotherFee(Fee anotherFee) {
+		this.anotherFee = anotherFee;
+	}
+	
+	
+	public FooComponent getCompon() {
+		return compon;
+	}
+	
+	public void setCompon(FooComponent compon) {
+		this.compon = compon;
+	}
+	
+	/**
+	 * Returns the count.
+	 * @return int
+	 */
+	public int getCount() {
+		return count;
+	}
+
+	/**
+	 * Sets the count.
+	 * @param count The count to set
+	 */
+	public void setCount(int count) {
+		this.count = count;
+	}
+
+}
+
+
+
+
+
+

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/FooComponent.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/FooComponent.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/FooComponent.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,114 @@
+//$Id$
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class FooComponent implements Serializable {
+	
+	int count;
+	String name;
+	Date[] importantDates;
+	FooComponent subcomponent;
+	Fee fee = new Fee();
+	GlarchProxy glarch;
+	
+	public boolean equals(Object that) {
+		FooComponent fc = (FooComponent) that;
+		return count==fc.count;
+	}
+	
+	public int hashCode() {
+		return count;
+	}
+	
+	public String toString() {
+		String result = "FooComponent: " + name + "=" + count;
+		result+="; dates=[";
+		if ( importantDates!=null) {
+			for ( int i=0; i<importantDates.length; i++ ) {
+				result+=(i==0 ?"":", ") + importantDates[i];
+			}
+		}
+		result+="]";
+		if ( subcomponent!=null ) {
+			result+= " (" + subcomponent + ")";
+		}
+		return result;
+	}
+	
+	public FooComponent() {}
+	
+	FooComponent(String name, int count, Date[] dates, FooComponent subcomponent) {
+		this.name = name;
+		this.count = count;
+		this.importantDates = dates;
+		this.subcomponent = subcomponent;
+	}
+	
+	FooComponent(String name, int count, Date[] dates, FooComponent subcomponent, Fee fee) {
+		this.name = name;
+		this.count = count;
+		this.importantDates = dates;
+		this.subcomponent = subcomponent;
+		this.fee = fee;
+	}
+	
+	public int getCount() {
+		return count;
+	}
+	public void setCount(int count) {
+		this.count = count;
+	}
+	
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	public Date[] getImportantDates() {
+		return importantDates;
+	}
+	public void setImportantDates(Date[] importantDates) {
+		this.importantDates = importantDates;
+	}
+	
+	public FooComponent getSubcomponent() {
+		return subcomponent;
+	}
+	public void setSubcomponent(FooComponent subcomponent) {
+		this.subcomponent = subcomponent;
+	}
+	
+	private String getNull() {
+		return null;
+	}
+	private void setNull(String str) throws Exception {
+		if (str!=null) throw new Exception("null component property");
+	}
+	public Fee getFee() {
+		return fee;
+	}
+	
+	public void setFee(Fee fee) {
+		this.fee = fee;
+	}
+	
+	public GlarchProxy getGlarch() {
+		return glarch;
+	}
+	
+	public void setGlarch(GlarchProxy glarch) {
+		this.glarch = glarch;
+	}	
+
+}
+
+
+
+
+
+
+

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping default-lazy="false" 
+	package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+
+    <class name="Glarch"
+    	table="`glarchez`"
+    	proxy="GlarchProxy"
+    	dynamic-update="true">
+
+        <!--cache-->
+        <id type="string" column="tha_key" length="32">
+            <generator class="uuid"/>
+        </id>
+        <version name="version"/>
+        <many-to-one name="next" column="next_" class="Glarch"/>
+        <dynamic-component name="dynaBean">
+        	<property name="foo" type="string"/>
+        	<property name="bar" type="integer"/>
+        </dynamic-component>
+        <list name="strings">
+            <key column="glarch_key"/>
+            <index column="`indx_`"/>
+            <element type="string" column="`tha_stryng`"/>
+        </list>
+        <list name="fooComponents" lazy="true" cascade="all">
+            <key column="glarch_key"/>
+            <index column="tha_indecks"/>
+            <composite-element class="FooComponent">
+                <property name="name" column="name_"/>
+                <property name="count" column="count_"/>
+                <nested-composite-element name="subcomponent" class="FooComponent">
+                    <property name="name" column="x_"/>
+                    <property name="count" column="y_"/>
+                </nested-composite-element>
+                <many-to-one name="fee" cascade="all" outer-join="true"/>
+            </composite-element>
+        </list>
+        <array name="proxyArray" element-class="GlarchProxy">
+        	<key column="array_key"/>
+        	<index column="array_indecks"/>
+        	<one-to-many class="Glarch"/>
+        </array>
+    </class>
+    
+     <class name="Fee" table="`the fees`">
+        <id type="string" name="key" column="id_" length="64" unsaved-value="null">
+            <generator class="uuid"/>
+        </id>
+        <property name="fi"/>
+        <many-to-one name="anotherFee"/>
+        <component name="compon" update="false">
+        	<property name="name"/>
+        	<property name="null" column="null_prop"/>
+        </component>
+    </class>
+
+</hibernate-mapping>
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Glarch.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,196 @@
+//$Id$
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.CallbackException;
+import org.hibernate.Session;
+import org.hibernate.classic.Lifecycle;
+
+public class Glarch implements GlarchProxy, Lifecycle, Serializable {
+
+	private int version;
+	private GlarchProxy next;
+	private short order;
+	private List strings;
+	private Map stringSets;
+	private List fooComponents;
+	private GlarchProxy[] proxyArray;
+	private transient Map dynaBean;
+	private String immutable;
+	private int derivedVersion;
+	private Object any;
+	private int x;
+	private String name;
+
+	public int getX() {
+		return x;
+	}
+	public void setX(int x) {
+		this.x = x;
+	}
+
+	public int getVersion() {
+		return version;
+	}
+
+	public void setVersion(int version) {
+		this.version = version;
+	}
+
+	public GlarchProxy getNext() {
+		return next;
+	}
+	public void setNext(GlarchProxy next) {
+		this.next = next;
+	}
+
+	public short getOrder() {
+		return order;
+	}
+	public void setOrder(short order) {
+		this.order = order;
+	}
+
+	public List getStrings() {
+		return strings;
+	}
+
+	public void setStrings(List strings) {
+		this.strings = strings;
+	}
+
+	public Map getStringSets() {
+		return stringSets;
+	}
+
+	public void setStringSets(Map stringSets) {
+		this.stringSets = stringSets;
+	}
+
+	public List getFooComponents() {
+		return fooComponents;
+	}
+
+	public void setFooComponents(List fooComponents) {
+		this.fooComponents = fooComponents;
+	}
+
+	public GlarchProxy[] getProxyArray() {
+		return proxyArray;
+	}
+	public void setProxyArray(GlarchProxy[] proxyArray) {
+		this.proxyArray = proxyArray;
+	}
+
+	public boolean onDelete(Session s) throws CallbackException {
+		return NO_VETO;
+	}
+
+	public void onLoad(Session s, Serializable id) {
+		if ( ! ( ( (String) id ).length()==32 ) ) throw new RuntimeException("id problem");
+	}
+
+	public boolean onSave(Session s) throws CallbackException {
+		dynaBean = new HashMap();
+		dynaBean.put("foo", "foo");
+		dynaBean.put("bar", new Integer(66));
+		immutable="never changes!";
+		return NO_VETO;
+	}
+
+	public boolean onUpdate(Session s) throws CallbackException {
+		return NO_VETO;
+	}
+
+	/*public Currency getCurrency() {
+		return currency;
+	}
+
+	public void setCurrency(Currency currency) {
+		this.currency = currency;
+	}*/
+
+	/**
+	 * Returns the dynaBean.
+	 * @return DynaBean
+	 */
+	public Map getDynaBean() {
+		return dynaBean;
+	}
+
+	/**
+	 * Sets the dynaBean.
+	 * @param dynaBean The dynaBean to set
+	 */
+	public void setDynaBean(Map dynaBean) {
+		this.dynaBean = dynaBean;
+	}
+
+	/**
+	 * Returns the immutable.
+	 * @return String
+	 */
+	public String getImmutable() {
+		return immutable;
+	}
+
+	/**
+	 * Sets the immutable.
+	 * @param immutable The immutable to set
+	 */
+	public void setImmutable(String immutable) {
+		this.immutable = immutable;
+	}
+
+	/**
+	 * Returns the derivedVersion.
+	 * @return int
+	 */
+	public int getDerivedVersion() {
+		return derivedVersion;
+	}
+
+	/**
+	 * Sets the derivedVersion.
+	 * @param derivedVersion The derivedVersion to set
+	 */
+	public void setDerivedVersion(int derivedVersion) {
+		this.derivedVersion = derivedVersion;
+	}
+
+	/**
+	 * Returns the any.
+	 * @return Object
+	 */
+	public Object getAny() {
+		return any;
+	}
+
+	/**
+	 * Sets the any.
+	 * @param any The any to set
+	 */
+	public void setAny(Object any) {
+		this.any = any;
+	}
+
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+
+}
+
+
+
+
+
+
+

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/GlarchProxy.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/GlarchProxy.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/GlarchProxy.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,46 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface GlarchProxy {
+	
+	public int getVersion();
+	public int getDerivedVersion();
+	public void setVersion(int version);
+	
+	public String getName();
+	public void setName(String name);
+	
+	public GlarchProxy getNext();
+	public void setNext(GlarchProxy next);
+	
+	public short getOrder();
+	public void setOrder(short order);
+	
+	public List getStrings();
+	public void setStrings(List strings);
+	
+	public Map getDynaBean();
+	public void setDynaBean(Map bean);
+	
+	public Map getStringSets();
+	public void setStringSets(Map stringSets);
+	
+	public List getFooComponents();
+	public void setFooComponents(List fooComponents);
+	
+	public GlarchProxy[] getProxyArray();
+	public void setProxyArray(GlarchProxy[] proxyArray);
+	
+	public Object getAny();
+	public void setAny(Object any);
+}
+
+
+
+
+
+
+

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Group2.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Group2.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Group2.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,20 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+public class Group2 {
+	private String name;
+	
+	Group2() {}
+	
+	public Group2(String name) {
+		this.name = name;
+	}
+	
+	public String getName() {
+		return name;
+	}
+	
+	void setName(String name) {
+		this.name = name;
+	}
+	
+}

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Hbm2HbmXmlTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -141,6 +141,12 @@
 		Node node = (Node) list.get(0);
 		assertEquals(node.getText(),"Basic");
 		
+		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/id/meta");
+		list = xpath.selectNodes(document);
+		assertEquals("Expected to get one meta element", 1, list.size());
+		node = (Node) list.get(0);
+		assertEquals(node.getText(),"basicId");	
+		
 		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property/meta");
 		list = xpath.selectNodes(document);
 		assertEquals("Expected to get one meta element", 1, list.size());
@@ -153,7 +159,6 @@
 		node = (Node) list.get(0);
 		assertEquals(node.getText(),"anotherone");
 		
-		
 	}
 
 	public void testCollectionAttributes() throws DocumentException {
@@ -170,23 +175,7 @@
 		Element node = (Element) list.get(0);
 		assertEquals("delete, update", node.attributeValue("cascade"));
 		
-		
-		
-//		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/property/meta");
-//		list = xpath.selectNodes(document);
-//		assertEquals("Expected to get one meta element", 1, list.size());
-//		node = (Node) list.get(0);
-//		assertEquals(node.getText(),"description");
-//		
-//		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/meta");
-//		list = xpath.selectNodes(document);
-//		assertEquals("Expected to get one meta element", 1, list.size());
-//		node = (Node) list.get(0);
-//		assertEquals(node.getText(),"anotherone");
-		
-		
 	}
-
 	
 	public void testComments() throws DocumentException {
 		File outputXml = new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/ClassFullAttribute.hbm.xml");
@@ -207,8 +196,6 @@
 		assertEquals("Expected to get one comment element", 1, list.size());
 		node = (Node) list.get(0);
 		assertEquals(node.getText(),"columnd comment");
-		
-
 	}
 
 	public void testNoComments() throws DocumentException {
@@ -233,7 +220,7 @@
 
 	/**
 	 * Special test for external Global settings were generated.
-	 * Test Access and Cacade setting but they are default values
+	 * Test Access and Cascade setting but they are default values
 	 * so they should not appear.
 	 */
 	public void testGlobalSettingsGeneratedAccessAndCascadeDefault()  throws Exception {
@@ -566,14 +553,6 @@
 		assertEquals("Unexpected class lock-mode for return element", "none", genAtt.getStringValue() );
 
 	}
-	    
-
-    private SAXReader getSAXReader() {
-    	SAXReader xmlReader = new SAXReader();
-    	xmlReader.setEntityResolver(new DTDEntityResolver() );
-    	xmlReader.setValidation(true);
-    	return xmlReader;
-    }
 	
 	protected String getBaseForMappings() {
 		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IdBagTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+  * Copyright (c) 2007-2008 Red Hat, Inc.
+  * Distributed under license by Red Hat, Inc. All rights reserved.
+  * This program is made available under the terms of the
+  * Eclipse Public License v1.0 which accompanies this distribution,
+  * and is available at http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class IdBagTest extends NonReflectiveTestCase {
+
+	private Exporter hbmexporter;
+
+	public IdBagTest(String name) {
+		super( name, "cfg2hbmoutput" );
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();		
+	}
+	
+	public void testAllFilesExistence() {
+
+		assertFalse(new File(getOutputDir().getAbsolutePath() + "/GeneralHbmSettings.hbm.xml").exists() );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/User2.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Group2.hbm.xml") );		
+	}
+	
+	public void testArtifactCollection() {
+		
+		assertEquals(2,hbmexporter.getArtifactCollector().getFileCount("hbm.xml"));
+		
+	}
+	
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+        
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "User2.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Group2.hbm.xml"));
+        
+        cfg.buildMappings();
+        
+    }
+	
+	public void testIdBagAttributes() {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "User2.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  this.getSAXReader();
+		
+		Document document;
+		try {
+			document = xmlReader.read(outputXml);
+			XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/idbag");
+			List list = xpath.selectNodes(document);
+			assertEquals("Expected to get one idbag element", 1, list.size());
+			Element node = (Element) list.get(0);
+			assertEquals(node.attribute( "table" ).getText(),"`UserGroups`");
+			assertEquals(node.attribute( "name" ).getText(),"groups");
+			assertEquals(node.attribute( "lazy" ).getText(),"false");
+		} catch (DocumentException e) {
+			fail("Can't parse file " + outputXml.getAbsolutePath());
+		}		
+	}
+	
+	public void testCollectionId() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "User2.hbm.xml");
+		SAXReader xmlReader =  this.getSAXReader();
+		
+		Document document = xmlReader.read(outputXml);	
+		
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/idbag/collection-id");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one collection-id element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "column" ).getText(),"userGroupId");
+		assertEquals(node.attribute( "type" ).getText(),"long");
+	
+		list = node.elements("generator");
+		assertEquals("Expected to get one generator element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "class" ).getText(),"increment");
+	}
+	
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+	
+	protected String[] getMappings() {
+		return new String[] { 
+				"UserGroup2.hbm.xml"				
+		};
+	}
+	    
+	public static Test suite() {
+		return new TestSuite(IdBagTest.class);
+	}
+
+}

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/InheritanceTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,83 +1,103 @@
-//$Id$
-
-/* 
- * Tests for generating the HBM documents from the Configuration data structure.
- * The generated XML document will be validated and queried to make sure the 
- * basic structure is correct in each test.
- */
-package org.hibernate.tool.hbm2x.hbm2hbmxml;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.hibernate.cfg.Configuration;
-import org.hibernate.tool.NonReflectiveTestCase;
-import org.hibernate.tool.hbm2x.Exporter;
-import org.hibernate.tool.hbm2x.HibernateMappingExporter;
-
-/**
- * this test should be fixed to have a proper model. currently a mix of subclass/joinedsubclass is in play.
- * @author max
- *
- */
-public class InheritanceTest extends NonReflectiveTestCase {
-
-	private Exporter hbmexporter;
-
-	public InheritanceTest(String name) {
-		super( name );
-	}
-
-	protected void setUp() throws Exception {
-		super.setUp();
-		
-		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
-		hbmexporter.start();		
-	}
-	
-	public void testAllFilesExistence() {
-
-		assertFalse(new File(getOutputDir().getAbsolutePath() + "/GeneralHbmSettings.hbm.xml").exists() );
-		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Human.hbm.xml") );
-		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Alien.hbm.xml") );		
-		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Animal.hbm.xml") );
-	}
-	
-	public void testArtifactCollection() {
-		
-		assertEquals(3,hbmexporter.getArtifactCollector().getFileCount("hbm.xml"));
-		
-	}
-	
-	public void testReadable() {
-        Configuration cfg = new Configuration();
-        
-        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Alien.hbm.xml"));
-        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Human.hbm.xml"));
-        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Animal.hbm.xml"));
-        
-        cfg.buildMappings();
-        
-    }
-	
-	
-   
-	
-	protected String getBaseForMappings() {
-		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
-	}
-	
-	protected String[] getMappings() {
-		return new String[] { 
-				"Aliens.hbm.xml"				
-		};
-	}
-	    
-	public static Test suite() {
-		return new TestSuite(InheritanceTest.class);
-	}
-
-	
-}
+//$Id$
+
+/*
+ * Tests for generating the HBM documents from the Configuration data structure.
+ * The generated XML document will be validated and queried to make sure the
+ * basic structure is correct in each test.
+ */
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * this test should be fixed to have a proper model. currently a mix of subclass/joinedsubclass is in play.
+ * @author max
+ *
+ */
+public class InheritanceTest extends NonReflectiveTestCase {
+
+	private Exporter hbmexporter;
+
+	public InheritanceTest(String name) {
+		super( name );
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();
+	}
+
+	public void testAllFilesExistence() {
+
+		assertFalse(new File(getOutputDir().getAbsolutePath() + "/GeneralHbmSettings.hbm.xml").exists() );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Human.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Alien.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Animal.hbm.xml") );
+	}
+
+	public void testArtifactCollection() {
+
+		assertEquals(3,hbmexporter.getArtifactCollector().getFileCount("hbm.xml"));
+
+	}
+
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Alien.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Human.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Animal.hbm.xml"));
+
+        cfg.buildMappings();
+    }
+
+	public void testComment() {
+		File outputXml = new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Alien.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  this.getSAXReader();
+
+		Document document;
+		try {
+				document = xmlReader.read(outputXml);
+				XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/joined-subclass/comment");
+				List list = xpath.selectNodes(document);
+				assertEquals("Expected to get one comment element", 1, list.size());
+			} catch (DocumentException e) {
+				fail("Can't parse file " + outputXml.getAbsolutePath());
+			}
+   }
+
+
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+
+	protected String[] getMappings() {
+		return new String[] {
+				"Aliens.hbm.xml"
+		};
+	}
+
+	public static Test suite() {
+		return new TestSuite(InheritanceTest.class);
+	}
+
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IntegerPropertyValue.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IntegerPropertyValue.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/IntegerPropertyValue.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,38 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+/**
+ * todo: describe IntegerPropertyValue
+ *
+ * @author Steve Ebersole
+ */
+public class IntegerPropertyValue implements PropertyValue {
+	private Long id;
+	private int value;
+
+	public IntegerPropertyValue() {
+	}
+
+	public IntegerPropertyValue(int value) {
+		this.value = value;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public int getValue() {
+		return value;
+	}
+
+	public void setValue(int value) {
+		this.value = value;
+	}
+
+	public String asString() {
+		return Integer.toString( value );
+	}
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ListArrayTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ListArrayTest.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ListArrayTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,147 @@
+/*******************************************************************************
+  * Copyright (c) 2007-2008 Red Hat, Inc.
+  * Distributed under license by Red Hat, Inc. All rights reserved.
+  * This program is made available under the terms of the
+  * Eclipse Public License v1.0 which accompanies this distribution,
+  * and is available at http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ListArrayTest extends NonReflectiveTestCase {
+
+	private String mappingFile = "Glarch.hbm.xml";
+
+	private Exporter hbmexporter;
+
+	/**
+	 * @param name
+	 */
+	public ListArrayTest(String name) {
+		super(name, "cfg2hbmoutput");
+	}
+
+
+	protected String[] getMappings() {
+		return new String[] {
+				mappingFile
+		};
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();
+	}
+
+	public void testAllFilesExistence() {
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "Fee.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "Glarch.hbm.xml") );
+	}
+
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Fee.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Glarch.hbm.xml"));
+
+        cfg.buildMappings();
+    }
+
+	public void testListNode() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Glarch.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/list");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get two list element", 2, list.size());
+		Element node = (Element) list.get(1); //second list
+		assertEquals(node.attribute( "name" ).getText(),"fooComponents");
+		assertEquals(node.attribute( "lazy" ).getText(),"true");
+		assertEquals(node.attribute( "cascade" ).getText(),"all");
+
+		list = node.elements("index");
+		assertEquals("Expected to get one index element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "column" ).getText(),"tha_indecks");
+
+		node = node.getParent();//list
+		list = node.elements("composite-element");
+		assertEquals("Expected to get one composite-element element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals("Expected to get two property element", 2, node.elements("property").size());
+
+		node = node.element("many-to-one");
+		assertEquals(node.attribute( "name" ).getText(),"fee");
+		assertEquals(node.attribute( "cascade" ).getText(),"all");
+		//TODO :assertEquals(node.attribute( "outer-join" ).getText(),"true");
+
+		node = node.getParent();//composite-element
+		node = node.element("nested-composite-element");
+		assertEquals(node.attribute( "name" ).getText(),"subcomponent");
+		assertEquals(node.attribute( "class" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.FooComponent");
+	}
+
+	public void testArrayNode() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Glarch.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/array");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one array element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"proxyArray");
+		assertEquals(node.attribute( "element-class" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.GlarchProxy");
+
+		list = node.elements("index");
+		assertEquals("Expected to get one index element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "column" ).getText(),"array_indecks");
+
+		node = node.getParent();//array
+		list = node.elements("one-to-many");
+		assertEquals("Expected to get one 'one-to-many' element", 1, list.size());
+
+	}
+
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+
+	public static Test suite() {
+		return new TestSuite(ListArrayTest.class);
+	}
+
+}

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/ManyToManyTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,8 +1,8 @@
 //$Id$
 
-/* 
+/*
  * Tests for generating the HBM documents from the Configuration data structure.
- * The generated XML document will be validated and queried to make sure the 
+ * The generated XML document will be validated and queried to make sure the
  * basic structure is correct in each test.
  */
 package org.hibernate.tool.hbm2x.hbm2hbmxml;
@@ -35,76 +35,118 @@
 
 	protected void setUp() throws Exception {
 		super.setUp();
-		
+
 		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
-		hbmexporter.start();		
+		hbmexporter.start();
 	}
-	
+
 	public void testAllFilesExistence() {
 
 		assertFalse(new File(getOutputDir().getAbsolutePath() + "/GeneralHbmSettings.hbm.xml").exists() );
 		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/User.hbm.xml") );
-		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Group.hbm.xml") );		
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Group.hbm.xml") );
 	}
-	
+
 	public void testArtifactCollection() {
-		
+
 		assertEquals(2,hbmexporter.getArtifactCollector().getFileCount("hbm.xml"));
-		
+
 	}
-	
+
 	public void testReadable() {
         Configuration cfg = new Configuration();
-        
+
         cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "User.hbm.xml"));
         cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Group.hbm.xml"));
-        
+
         cfg.buildMappings();
-        
+
     }
-	
+
 	public void testManyToMany() throws DocumentException {
 		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "User.hbm.xml");
 		assertFileAndExists(outputXml);
 
 		SAXReader xmlReader =  this.getSAXReader();
-		
-		Document document = xmlReader.read(outputXml);		
-	
+
+		Document document = xmlReader.read(outputXml);
+
 		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/many-to-many");
 		List list = xpath.selectNodes(document);
 		assertEquals("Expected to get one many-to-many element", 1, list.size());
 		Element node = (Element) list.get(0);
 		assertEquals(node.attribute( "entity-name" ).getText(),"org.hibernate.tool.hbm2x.hbm2hbmxml.Group");
-		
-		
+
+
 		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
 		list = xpath.selectNodes(document);
 		assertEquals("Expected to get one set element", 1, list.size());
 		node = (Element) list.get(0);
 		assertEquals(node.attribute( "table" ).getText(),"UserGroup");
-		
-		
+
+
 	}
-	
-	
-    private SAXReader getSAXReader() {
-    	SAXReader xmlReader = new SAXReader();
-    	xmlReader.setEntityResolver(new DTDEntityResolver() );
-    	xmlReader.setValidation(true);
-    	return xmlReader;
-    }
-	
+
+		public void testCompositeId() throws DocumentException {
+				File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Group.hbm.xml");
+		 		SAXReader xmlReader =  this.getSAXReader();
+
+				Document document = xmlReader.read(outputXml);
+
+				XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class");
+		 		List list = xpath.selectNodes(document);
+				assertEquals("Expected to get one class element", 1, list.size());
+		 		Element node = (Element) list.get(0);
+
+				assertEquals(node.attribute( "table" ).getText(),"`Group`");
+
+				xpath = DocumentHelper.createXPath("//hibernate-mapping/class/composite-id");
+				list = xpath.selectNodes(document);
+				assertEquals("Expected to get one composite-id element", 1, list.size());
+
+
+				xpath = DocumentHelper.createXPath("//hibernate-mapping/class/composite-id/key-property");
+		 		list = xpath.selectNodes(document);
+				assertEquals("Expected to get two key-property elements", 2, list.size());
+		 		node = (Element) list.get(0);
+				assertEquals(node.attribute( "name" ).getText(),"name");
+				node = (Element) list.get(1);
+				assertEquals(node.attribute( "name" ).getText(),"org");
+			}
+
+			public void testSetAttributes() {
+					File outputXml = new File(getOutputDir(),  getBaseForMappings() + "Group.hbm.xml");
+					assertFileAndExists(outputXml);
+
+					SAXReader xmlReader =  this.getSAXReader();
+
+
+					Document document;
+					try {
+						document = xmlReader.read(outputXml);
+						XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
+						List list = xpath.selectNodes(document);
+						assertEquals("Expected to get one set element", 1, list.size());
+						Element node = (Element) list.get(0);
+						assertEquals(node.attribute( "table" ).getText(),"UserGroup");
+						assertEquals(node.attribute( "name" ).getText(),"users");
+						assertEquals(node.attribute( "inverse" ).getText(),"true");
+						assertEquals(node.attribute( "lazy" ).getText(),"extra");
+					} catch (DocumentException e) {
+						fail("Can't parse file " + outputXml.getAbsolutePath());
+					}
+			 	}
+
 	protected String getBaseForMappings() {
 		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
 	}
-	
+
 	protected String[] getMappings() {
-		return new String[] { 
-				"UserGroup.hbm.xml"				
+		return new String[] {
+				"UserGroup.hbm.xml"
 		};
 	}
-	    
+
 	public static Test suite() {
 		return new TestSuite(ManyToManyTest.class);
 	}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/MapAndAnyTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,192 @@
+/*******************************************************************************
+  * Copyright (c) 2007-2008 Red Hat, Inc.
+  * Distributed under license by Red Hat, Inc. All rights reserved.
+  * This program is made available under the terms of the
+  * Eclipse Public License v1.0 which accompanies this distribution,
+  * and is available at http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.Any;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class MapAndAnyTest extends NonReflectiveTestCase {
+
+	private String mappingFile = "Properties.hbm.xml";
+
+	private Exporter hbmexporter;
+
+	/**
+	 * @param name
+	 */
+	public MapAndAnyTest(String name) {
+		super(name, "cfg2hbmoutput");
+	}
+
+
+	protected String[] getMappings() {
+		return new String[] {
+				mappingFile
+		};
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();
+	}
+
+	public void testAllFilesExistence() {
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "ComplexPropertyValue.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "IntegerPropertyValue.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "StringPropertyValue.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + "PropertySet.hbm.xml") );
+	}
+
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "ComplexPropertyValue.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "IntegerPropertyValue.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "StringPropertyValue.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "PropertySet.hbm.xml"));
+
+        cfg.buildMappings();
+    }
+
+	public void testAnyNode() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "PropertySet.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/any");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one any element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"someSpecificProperty");
+		assertEquals(node.attribute( "id-type" ).getText(),"long");
+		assertEquals(node.attribute( "meta-type" ).getText(),"string");
+		assertEquals(node.attribute( "cascade" ).getText(), "all");
+
+		list = node.elements("column");
+		assertEquals("Expected to get two column elements", 2, list.size());
+
+		list = node.elements("meta-value");
+		assertEquals("Expected to get three meta-value elements", 3, list.size());
+		node = (Element) list.get(0);
+		String className = node.attribute( "class" ).getText();
+		assertNotNull("Expected class attribute in meta-value", className);
+		if (className.indexOf("IntegerPropertyValue") > 0){
+			assertEquals(node.attribute( "value" ).getText(),"I");
+		} else if (className.indexOf("StringPropertyValue") > 0){
+			assertEquals(node.attribute( "value" ).getText(),"S");
+		} else {
+			assertTrue(className.indexOf("ComplexPropertyValue") > 0);
+			assertEquals(node.attribute( "value" ).getText(),"C");
+		}
+	}
+
+	public void testMetaValueRead() throws Exception{
+		String oldMappingFile = mappingFile;
+		mappingFile = "Person2.hbm.xml";
+
+		super.setUp();//rebuld cfg
+
+		Configuration config = getCfg();
+		PersistentClass pc = config.getClassMapping("org.hibernate.tool.hbm2x.hbm2hbmxml.Person2");
+		assertNotNull(pc);
+		Property prop = pc.getProperty("data");
+		assertNotNull(prop);
+		assertTrue(prop.getValue() instanceof Any);
+		Any any = (Any) prop.getValue();
+		assertTrue("Expected to get one meta-value element", any.getMetaValues() != null);
+		assertEquals("Expected to get one meta-value element", 1, any.getMetaValues().size());
+		mappingFile = oldMappingFile;
+	}
+
+	public void testMapManyToAny() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "PropertySet.hbm.xml");
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/map");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one any element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"generalProperties");
+		assertEquals(node.attribute( "table" ).getText(),"T_GEN_PROPS");
+		assertEquals(node.attribute( "lazy" ).getText(),"true");
+		assertEquals(node.attribute( "cascade" ).getText(), "all");
+
+
+		list = node.elements("key");
+		assertEquals("Expected to get one key element", 1, list.size());
+
+		list = node.elements("map-key");
+		assertEquals("Expected to get one map-key element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "type" ).getText(),"string");
+		list = node.elements("column");
+		assertEquals("Expected to get one column element", 1, list.size());
+		node = node.getParent();//map
+
+		list = node.elements("many-to-any");
+		assertEquals("Expected to get one many-to-any element", 1, list.size());
+		node = (Element) list.get(0);
+
+		list = node.elements("column");
+		assertEquals("Expected to get two column elements", 2, list.size());
+
+		list = node.elements("meta-value");
+		assertEquals("Expected to get two meta-value elements", 2, list.size());
+		node = (Element) list.get(0);
+		String className = node.attribute( "class" ).getText();
+		assertNotNull("Expected class attribute in meta-value", className);
+		if (className.indexOf("IntegerPropertyValue") > 0){
+			assertEquals(node.attribute( "value" ).getText(),"I");
+		} else {
+			assertTrue(className.indexOf("StringPropertyValue") > 0);
+			assertEquals(node.attribute( "value" ).getText(),"S");
+		}
+	}
+
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+
+	public static Test suite() {
+		return new TestSuite(MapAndAnyTest.class);
+	}
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Named.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Named.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Named.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,13 @@
+//$Id$
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+
+public interface Named {
+	public String getName();
+}
+
+
+
+
+
+

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/OneToOneTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,125 +1,117 @@
-//$Id$
-
-/* 
- * Tests for generating the HBM documents from the Configuration data structure.
- * The generated XML document will be validated and queried to make sure the 
- * basic structure is correct in each test.
- */
-package org.hibernate.tool.hbm2x.hbm2hbmxml;
-
-import java.io.File;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.XPath;
-import org.dom4j.io.SAXReader;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.tool.NonReflectiveTestCase;
-import org.hibernate.tool.hbm2ddl.SchemaValidator;
-import org.hibernate.tool.hbm2x.Exporter;
-import org.hibernate.tool.hbm2x.HibernateMappingExporter;
-import org.hibernate.util.DTDEntityResolver;
-
-
-
-public class OneToOneTest extends NonReflectiveTestCase {
-
-	private Exporter hbmexporter;
-
-	public OneToOneTest(String name) {
-		super( name );
-	}
-
-	protected void setUp() throws Exception {
-		super.setUp();
-		
-		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
-		hbmexporter.start();		
-	}
-	
-	public void testAllFilesExistence() {
-
-		assertFalse(new File(getOutputDir().getAbsolutePath() + "/GeneralHbmSettings.hbm.xml").exists() );
-		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Person.hbm.xml") );
-		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Address.hbm.xml") );		
-	}
-	
-	public void testArtifactCollection() {
-		
-		assertEquals(2,hbmexporter.getArtifactCollector().getFileCount("hbm.xml"));
-		
-	}
-	
-	public void testReadable() {
-        Configuration cfg = new Configuration();
-        
-        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Person.hbm.xml"));
-        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Address.hbm.xml"));
-        
-        cfg.buildMappings();
-                
-        
-    }
-	
-	public void testOneToOne() throws DocumentException {
-		Document document = getXMLDocument(getBaseForMappings() + "Person.hbm.xml");		
-	
-		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/one-to-one");
-		List list = xpath.selectNodes(document);
-		assertEquals("Expected to get one-to-one element", 1, list.size());
-		Element node = (Element) list.get(0);
-		assertEquals(node.attribute( "name" ).getText(),"address");
-		assertEquals(node.attribute( "constrained" ).getText(),"false");
-		
-		document = getXMLDocument(getBaseForMappings() + "Address.hbm.xml");
-		
-		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/one-to-one");
-		list = xpath.selectNodes(document);
-		assertEquals("Expected to get one set element", 1, list.size());
-		node = (Element) list.get(0);
-		assertEquals(node.attribute( "name" ).getText(),"person");
-		assertEquals(node.attribute( "constrained" ).getText(),"true");
-		
-		
-	}
-
-	private Document getXMLDocument(String location) throws DocumentException {
-		File outputXml = new File(getOutputDir(),  location);
-		assertFileAndExists(outputXml);
-
-		SAXReader xmlReader =  this.getSAXReader();
-		
-		Document document = xmlReader.read(outputXml);
-		return document;
-	}
-	
-	
-    private SAXReader getSAXReader() {
-    	SAXReader xmlReader = new SAXReader();
-    	xmlReader.setEntityResolver(new DTDEntityResolver() );
-    	xmlReader.setValidation(true);
-    	return xmlReader;
-    }
-	
-	protected String getBaseForMappings() {
-		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
-	}
-	
-	protected String[] getMappings() {
-		return new String[] { 
-				"PersonAddressOneToOnePrimaryKey.hbm.xml"				
-		};
-	}
-	    
-	public static Test suite() {
-		return new TestSuite(OneToOneTest.class);
-	}
-
-}
+//$Id$
+
+/* 
+ * Tests for generating the HBM documents from the Configuration data structure.
+ * The generated XML document will be validated and queried to make sure the 
+ * basic structure is correct in each test.
+ */
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2ddl.SchemaValidator;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+import org.hibernate.util.DTDEntityResolver;
+
+
+
+public class OneToOneTest extends NonReflectiveTestCase {
+
+	private Exporter hbmexporter;
+
+	public OneToOneTest(String name) {
+		super( name );
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();		
+	}
+	
+	public void testAllFilesExistence() {
+
+		assertFalse(new File(getOutputDir().getAbsolutePath() + "/GeneralHbmSettings.hbm.xml").exists() );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Person.hbm.xml") );
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath() + "/org/hibernate/tool/hbm2x/hbm2hbmxml/Address.hbm.xml") );		
+	}
+	
+	public void testArtifactCollection() {
+		
+		assertEquals(2,hbmexporter.getArtifactCollector().getFileCount("hbm.xml"));
+		
+	}
+	
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+        
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Person.hbm.xml"));
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + "Address.hbm.xml"));
+        
+        cfg.buildMappings();
+                
+        
+    }
+	
+	public void testOneToOne() throws DocumentException {
+		Document document = getXMLDocument(getBaseForMappings() + "Person.hbm.xml");		
+	
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/one-to-one");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one-to-one element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"address");
+		assertEquals(node.attribute( "constrained" ).getText(),"false");
+		
+		document = getXMLDocument(getBaseForMappings() + "Address.hbm.xml");
+		
+		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/one-to-one");
+		list = xpath.selectNodes(document);
+		assertEquals("Expected to get one set element", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"person");
+		assertEquals(node.attribute( "constrained" ).getText(),"true");
+		
+		
+	}
+
+	private Document getXMLDocument(String location) throws DocumentException {
+		File outputXml = new File(getOutputDir(),  location);
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  this.getSAXReader();
+		
+		Document document = xmlReader.read(outputXml);
+		return document;
+	}
+	
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+	
+	protected String[] getMappings() {
+		return new String[] { 
+				"PersonAddressOneToOnePrimaryKey.hbm.xml"				
+		};
+	}
+	    
+	public static Test suite() {
+		return new TestSuite(OneToOneTest.class);
+	}
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+
+    <class name="Person2" table="T_ANY_PERSON">
+        <id name="id" column="ID_">
+            <generator class="increment" />
+        </id>
+        <property name="name" />
+        <any name="data" id-type="long" cascade="none" meta-type="string">
+            <meta-value value="A" class="Address2"/>
+            <column name="DATATYPE_"/>
+            <column name="DATAID_"/>
+        </any>
+    </class>
+
+    <class name="Address2" table="T_ANY_ADDRESS">
+        <id name="id" column="ID_">
+            <generator class="increment" />
+        </id>
+        <set name="lines" table="LINE">
+            <key column="ADDRESS" />
+            <element type="string" />
+        </set>
+    </class>
+
+</hibernate-mapping>

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Person2.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,37 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+/**
+ * todo: describe Person
+ *
+ * @author Steve Ebersole
+ */
+public class Person2 {
+	private Long id;
+	private String name;
+	private Object data;
+
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public void setData(Object data) {
+		this.data = data;
+	}
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Properties.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+
+    <class name="PropertySet" table="T_PROP_SET">
+        <id name="id" column="ID" type="long">
+            <generator class="increment"/>
+        </id>
+        <property name="name" column="NAME" type="string"/>
+        <any name="someSpecificProperty" id-type="long" meta-type="string" cascade="all">
+            <meta-value value="I" class="IntegerPropertyValue"/>
+            <meta-value value="S" class="StringPropertyValue"/>
+            <meta-value value="C" class="ComplexPropertyValue" />
+            <column name="S_S_PROP_TYPE"/>
+            <column name="S_S_PROP_ID"/>
+        </any>
+        <map name="generalProperties" table="T_GEN_PROPS" lazy="true" cascade="all">
+            <key column="PROP_SET_ID"/>
+            <map-key type="string" column="GEN_PROP_NAME"/>
+            <many-to-any id-type="long" meta-type="string">
+                <meta-value value="I" class="IntegerPropertyValue"/>
+                <meta-value value="S" class="StringPropertyValue"/>
+                <column name="PROP_TYPE"/>
+                <column name="PROP_ID"/>
+            </many-to-any>
+        </map>
+    </class>
+
+    <class name="StringPropertyValue" table="T_CHAR_PROP">
+        <id name="id" column="ID" type="long">
+            <generator class="increment"/>
+        </id>
+        <property name="value" column="VAL" not-null="true" type="string"/>
+    </class>
+
+    <class name="IntegerPropertyValue" table="T_NUM_PROP">
+        <id name="id" column="ID" type="long">
+            <generator class="increment"/>
+        </id>
+        <property name="value" column="VAL" not-null="true" type="integer"/>
+    </class>
+
+    <class name="ComplexPropertyValue" table="T_COMPLEX_PROP">
+        <id name="id" column="ID" type="long">
+            <generator class="increment"/>
+        </id>
+        <map name="subProperties" table="T_COMPLEX_SUB_PROPS" lazy="true">
+            <key column="PROP_ID" />
+            <map-key type="string" column="SUB_PROP_NAME" />
+            <element type="string" column="SUB_PROP_VAL" />
+        </map>
+    </class>
+</hibernate-mapping>
\ No newline at end of file

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertySet.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertySet.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertySet.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,55 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * todo: describe PropertySet
+ *
+ * @author Steve Ebersole
+ */
+public class PropertySet {
+	private Long id;
+	private String name;
+	private PropertyValue someSpecificProperty;
+	private Map generalProperties = new HashMap();
+
+	public PropertySet() {
+	}
+
+	public PropertySet(String name) {
+		this.name = name;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public PropertyValue getSomeSpecificProperty() {
+		return someSpecificProperty;
+	}
+
+	public void setSomeSpecificProperty(PropertyValue someSpecificProperty) {
+		this.someSpecificProperty = someSpecificProperty;
+	}
+
+	public Map getGeneralProperties() {
+		return generalProperties;
+	}
+
+	public void setGeneralProperties(Map generalProperties) {
+		this.generalProperties = generalProperties;
+	}
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertyValue.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertyValue.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/PropertyValue.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,10 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+/**
+ * todo: describe PropertyValue
+ *
+ * @author Steve Ebersole
+ */
+public interface PropertyValue {
+	public String asString();
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+  
+-->
+
+<hibernate-mapping package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+	
+	<class name="Search">
+		<id name="searchString"/>
+		<set name="searchResults" sort="natural">
+			<key column="searchString"/>
+			<element column="text" type="string"/>
+		</set>
+	</class>
+	
+</hibernate-mapping>
+

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Search.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+public class Search {
+	private String searchString;
+	private SortedSet searchResults = new TreeSet();
+	
+	Search() {}
+	
+	public Search(String string) {
+		searchString = string;
+	}
+	
+	public SortedSet getSearchResults() {
+		return searchResults;
+	}
+	public void setSearchResults(SortedSet searchResults) {
+		this.searchResults = searchResults;
+	}
+	public String getSearchString() {
+		return searchString;
+	}
+	public void setSearchString(String searchString) {
+		this.searchString = searchString;
+	}
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/SetElementTest.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+  * Copyright (c) 2007-2008 Red Hat, Inc.
+  * Distributed under license by Red Hat, Inc. All rights reserved.
+  * This program is made available under the terms of the
+  * Eclipse Public License v1.0 which accompanies this distribution,
+  * and is available at http://www.eclipse.org/legal/epl-v10.html
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.io.File;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.XPath;
+import org.dom4j.io.SAXReader;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.NonReflectiveTestCase;
+import org.hibernate.tool.hbm2x.Exporter;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+import org.hibernate.util.DTDEntityResolver;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class SetElementTest extends NonReflectiveTestCase {
+
+	private String mappingFile = "Search.hbm.xml";
+
+	private Exporter hbmexporter;
+
+	/**
+	 * @param name
+	 */
+	public SetElementTest(String name) {
+		super(name, "cfg2hbmoutput");
+	}
+
+
+	protected String[] getMappings() {
+		return new String[] {
+				mappingFile
+		};
+	}
+
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		hbmexporter = new HibernateMappingExporter(getCfg(), getOutputDir() );
+		hbmexporter.start();
+	}
+
+	public void testAllFilesExistence() {
+		assertFileAndExists(new File(getOutputDir().getAbsolutePath(),  getBaseForMappings() + mappingFile) );
+	}
+
+	public void testReadable() {
+        Configuration cfg = new Configuration();
+
+        cfg.addFile(new File(getOutputDir(), getBaseForMappings() + mappingFile));
+
+        cfg.buildMappings();
+    }
+
+	public void testKey() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + mappingFile);
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/key");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one key element", 1, list.size());
+		Element node = (Element) list.get(0);
+		if (node.attribute( "column" ) != null){//implied attribute
+			assertEquals(node.attribute( "column" ).getText(),"searchString");
+		} else {
+			node = node.element("column");
+			assertEquals(node.attribute( "name" ).getText(),"searchString");
+		}
+	}
+
+	public void testSetElement() throws DocumentException {
+		File outputXml = new File(getOutputDir(),  getBaseForMappings() + mappingFile);
+		assertFileAndExists(outputXml);
+
+		SAXReader xmlReader =  getSAXReader();
+
+		Document document = xmlReader.read(outputXml);
+
+		XPath xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set");
+		List list = xpath.selectNodes(document);
+		assertEquals("Expected to get one set element", 1, list.size());
+		Element node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(),"searchResults");
+
+
+		xpath = DocumentHelper.createXPath("//hibernate-mapping/class/set/element");
+		list = xpath.selectNodes(document);
+		assertEquals("Expected to get one element 'element'", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "type" ).getText(), "string");
+		list = node.selectNodes("column");
+		assertEquals("Expected to get one element 'column'", 1, list.size());
+		node = (Element) list.get(0);
+		assertEquals(node.attribute( "name" ).getText(), "text");
+	}
+
+	protected String getBaseForMappings() {
+		return "org/hibernate/tool/hbm2x/hbm2hbmxml/";
+	}
+
+	public static Test suite() {
+		return new TestSuite(SetElementTest.class);
+	}
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/StringPropertyValue.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/StringPropertyValue.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/StringPropertyValue.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,38 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+/**
+ * todo: describe StringPropertyValue
+ *
+ * @author Steve Ebersole
+ */
+public class StringPropertyValue implements PropertyValue {
+	private Long id;
+	private String value;
+
+	public StringPropertyValue() {
+	}
+
+	public StringPropertyValue(String value) {
+		this.value = value;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	public String asString() {
+		return value;
+	}
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Super.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Super.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Super.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,15 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+public class Super {
+
+	protected String name;
+
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+
+}

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/User2.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/User2.java	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/User2.java	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,33 @@
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class User2 {
+	private String name;
+	private List groups = new ArrayList();
+	
+	User2() {}
+	
+	public User2(String name) {
+		this.name = name;
+	}
+
+	public String getName() {
+		return name;
+	}
+	
+
+	void setName(String name) {
+		this.name = name;
+	}
+
+	public List getGroups() {
+		return groups;
+	}
+	
+	void setGroups(List groups) {
+		this.groups = groups;
+	}
+	
+}

Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup.hbm.xml	2009-02-26 05:42:08 UTC (rev 16036)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -1,52 +1,52 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC 
-	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!-- 
-
-  This mapping demonstrates how to map a many-to-many
-  association with a shared attribute in the primary keys
-  of the associated entities.
-     
--->
-
-<hibernate-mapping 
-	package="org.hibernate.tool.hbm2x.hbm2hbmxml">
-	
-	<class name="User" table="`User`">
-		<composite-id>
-			<key-property name="name"/>
-			<key-property name="org"/>
-		</composite-id>
-		<set name="groups" table="UserGroup">
-			<key>
-				<column name="userName"/>
-				<column name="org"/>
-			</key>
-			<many-to-many class="Group">
-				<column name="groupName"/>
-				<formula>org</formula>
-			</many-to-many>
-		</set>
-	</class>
-	
-	<class name="Group" table="`Group`">
-		<composite-id>
-			<key-property name="name"/>
-			<key-property name="org"/>
-		</composite-id>
-		<property name="description"/>
-		<set name="users" table="UserGroup" inverse="true">
-			<key>
-				<column name="groupName"/>
-				<column name="org"/>
-			</key>
-			<many-to-many class="User">
-				<column name="userName"/>
-				<formula>org</formula>
-			</many-to-many>
-		</set>
-	</class>
-	
-</hibernate-mapping>
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+  This mapping demonstrates how to map a many-to-many
+  association with a shared attribute in the primary keys
+  of the associated entities.
+
+-->
+
+<hibernate-mapping
+	package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+
+	<class name="User" table="`User`">
+		<composite-id>
+			<key-property name="name"/>
+			<key-property name="org"/>
+		</composite-id>
+		<set name="groups" table="UserGroup" lazy="extra">
+			<key>
+				<column name="userName"/>
+				<column name="org"/>
+			</key>
+			<many-to-many class="Group">
+				<column name="groupName"/>
+				<formula>org</formula>
+			</many-to-many>
+		</set>
+	</class>
+
+	<class name="Group" table="`Group`">
+		<composite-id>
+			<key-property name="name"/>
+			<key-property name="org"/>
+		</composite-id>
+		<property name="description"/>
+		<set name="users" table="UserGroup" inverse="true" lazy="extra">
+			<key>
+				<column name="groupName"/>
+				<column name="org"/>
+			</key>
+			<many-to-many class="User">
+				<column name="userName"/>
+				<formula>org</formula>
+			</many-to-many>
+		</set>
+	</class>
+
+</hibernate-mapping>

Added: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml	                        (rev 0)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/UserGroup2.hbm.xml	2009-02-26 07:02:45 UTC (rev 16037)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC 
+	"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!-- 
+
+  This mapping demonstrates how to use an idbag to represent
+  a many-to-many association where the association table has
+  a surrogate key.
+     
+-->
+
+<hibernate-mapping package="org.hibernate.tool.hbm2x.hbm2hbmxml">
+	
+	<class name="User2" table="`Users`">
+		<id name="name"/>
+		
+		<idbag name="groups" 
+				order-by="groupName asc" 
+				table="`UserGroups`" lazy="false">
+			<collection-id column="userGroupId" 
+					type="long">
+				<generator class="increment"/>
+			</collection-id>
+			<key column="userName"/>
+			<many-to-many column="groupName" 
+					class="Group2"/>
+		</idbag>
+		
+	</class>
+	
+	<class name="Group2" table="`Groups`">
+		<id name="name"/>
+	</class>
+	
+
+</hibernate-mapping>




More information about the hibernate-commits mailing list