Ok. The order is correct. There was an error in the mapping files I was using for the test. There was also a bug in the code of my previous message. I think that this should be the correct version of EntityPersister.postInstantiate in order to manage nested multiple columns composite-id.
public void postInstantiate(SessionFactoryImplementor factory) throws MappingException { HashMap mods = new HashMap(); Iterator iter = typesByPropertyPath.entrySet().iterator(); while ( iter.hasNext() ) { Map.Entry e = (Map.Entry) iter.next(); Type type = (Type) e.getValue(); if ( type.isEntityType() ) { String path = (String) e.getKey(); String[] columns = (String[]) columnNamesByPropertyPath.get(path); if ( columns.length==0 ) columns = getIdentifierColumnNames(); //ie. a 1-to-one association EntityType etype = (EntityType) type; Type idType = factory.getIdentifierType( etype.getPersistentClass() ); String idpath = path + '.' + PathExpressionParser.ENTITY_ID; mods.put(idpath, idType); columnNamesByPropertyPath.put(idpath, columns); if ( idType.isComponentType() ) { AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); if (actype.getColumnSpan(factory) != columns.length) throw new MappingException("broken mapping for: " + getClassName() + '.' + path); int j = 0; String[] componentColumns; for ( int i=0; i<props.length; i++ ) { String subidpath = idpath + '.' + props[i]; componentColumns = new String[actype.getSubtypes()[i].getColumnSpan(factory)]; for (int k = 0; k < componentColumns.length; k++) componentColumns[k] = columns[j++]; columnNamesByPropertyPath.put( subidpath, componentColumns ); mods.put( subidpath, actype.getSubtypes()[i] ); } } } } typesByPropertyPath.putAll(mods); [..etc...] stefano -----Messaggio originale----- Da: Travelli Stefano Inviato: mercoledì 12 febbraio 2003 12.36 A: [EMAIL PROTECTED] Oggetto: R: [Hibernate] [ hibernate-Bugs-684496 ] Nested multiple columns composite-id causes "broken mapping" I'm trying to change EntityPersister.postInstantiate method in order to fix the nested multiple columns composite-id. With this implementation the code take care of the exact number of columns for each component of the composite-id. However it doesn't work because the order with which the columns come is not related to the order of getSubtypes[].... Is out there someone who know how to get the component columns list as it were written in the mapping file? public void postInstantiate(SessionFactoryImplementor factory) throws MappingException { HashMap mods = new HashMap(); Iterator iter = typesByPropertyPath.entrySet().iterator(); while ( iter.hasNext() ) { Map.Entry e = (Map.Entry) iter.next(); Type type = (Type) e.getValue(); if ( type.isEntityType() ) { String path = (String) e.getKey(); String[] columns = (String[]) columnNamesByPropertyPath.get(path); if ( columns.length==0 ) columns = getIdentifierColumnNames(); //ie. a 1-to-one association EntityType etype = (EntityType) type; Type idType = factory.getIdentifierType( etype.getPersistentClass() ); String idpath = path + '.' + PathExpressionParser.ENTITY_ID; mods.put(idpath, idType); columnNamesByPropertyPath.put(idpath, columns); if ( idType.isComponentType() ) { AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); // Changes start here if (actype.getColumnSpan(factory) != columns.length) throw new MappingException("broken mapping for: " + getClassName() + '.' + path); //if (props.length!=columns.length) int j; String[] componentColumns; for ( int i=0; i<props.length; i++ ) { String subidpath = idpath + '.' + props[i]; j = 0; // allocate a String[] with the real number of component columns componentColumns = new String[actype.getSubtypes()[i].getColumnSpan(factory)]; // populate the array, but columns come in wrong order!! for (int k = 0; k < componentColumns.length; k++) componentColumns[k] = columns[j++]; columnNamesByPropertyPath.put( subidpath, componentColumns ); mods.put( subidpath, actype.getSubtypes()[i] ); } } } [...snip] Help! stefano -----Messaggio originale----- Da: SourceForge.net [mailto:[EMAIL PROTECTED] Inviato: martedì 11 febbraio 2003 11.23 A: [EMAIL PROTECTED] Oggetto: [Hibernate] [ hibernate-Bugs-684496 ] Nested multiple columns composite-id causes "broken mapping" Bugs item #684496, was opened at 2003-02-11 11:20 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=428708&aid=684496&group_id=40712 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Stefano Travelli (stefanotravelli) Assigned to: Nobody/Anonymous (nobody) >Summary: Nested multiple columns composite-id causes "broken mapping" Initial Comment: A composite-id composed by a key-many-to-one component witch in turn has a composite-id, causes a "broken mapping error...". Maybe this is somehow related to https://sourceforge.net/forum/forum.php?thread_id=800929&forum_id=128638 Please, find the attached test case. It should be extracted in cirrus.hibernate.test under Hibernate 1.2. stefano ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=428708&aid=684496&group_id=40712 ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld =omething 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel