Index: topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java diff -u topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.21 topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.22 --- topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java:1.21 Fri Mar 7 09:34:09 2008 +++ topia2/src/java/org/codelutin/topia/generator/GeneratorUtil.java Fri Mar 7 19:14:32 2008 @@ -25,9 +25,9 @@ * * @author Arnaud Thimel * - * @version $Revision: 1.21 $ + * @version $Revision: 1.22 $ * - * Mise a jour: $Date: 2008-03-07 09:34:09 $ par : $Author: thimel $ + * Mise a jour: $Date: 2008-03-07 19:14:32 $ par : $Author: thimel $ */ package org.codelutin.topia.generator; @@ -36,6 +36,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import java.util.Set; import org.apache.commons.lang.StringUtils; @@ -509,11 +511,11 @@ */ public static String getNMultiplicityInterfaceType(ObjectModelAttribute attr) { if (attr.hasStereotype(STEREOTYPE_UNIQUE)) { - return "java.util.Set"; - } else if (attr.isOrdered()) { - return "java.util.List"; + return Set.class.getName(); + } else if (attr.isIndexed() || attr.isOrdered()) { + return List.class.getName(); } - return "java.util.Collection"; + return Collection.class.getName(); } /** @@ -522,11 +524,15 @@ */ public static String getNMultiplicityObjectType(ObjectModelAttribute attr) { if (attr.hasStereotype(STEREOTYPE_UNIQUE)) { - return "java.util.HashSet"; - } else if (attr.isOrdered()) { - return "java.util.ArrayList"; + return HashSet.class.getName(); + } else if (attr.isIndexed() || attr.isOrdered()) { + //On considère qu'on ne sait pas traiter vraiment l'attribut "ordered" + // puisqu'on va conserver l'ordre d'insertion, et non un ordre en + // fonction d'un élément donné. Donc on renvoi une ArrayList + return ArrayList.class.getName(); } - return "java.util.ArrayList"; + LinkedList.class.getName(); + return ArrayList.class.getName(); } /** @@ -536,9 +542,10 @@ public static String getNMultiplicityHibernateType(ObjectModelAttribute attr) { if (attr.hasStereotype(STEREOTYPE_UNIQUE)) { return "set"; - } else if (attr.isOrdered()) { + } else if (attr.isIndexed()) { return "list"; } + //attr.isOrdered() - On génère le ordered en bag return "bag"; } Index: topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java diff -u topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.44 topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.45 --- topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.44 Fri Mar 7 09:34:09 2008 +++ topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java Fri Mar 7 19:14:33 2008 @@ -24,9 +24,9 @@ * Created: 12 déc. 2005 * * @author Arnaud Thimel -* @version $Revision: 1.44 $ +* @version $Revision: 1.45 $ * -* Mise a jour: $Date: 2008-03-07 09:34:09 $ +* Mise a jour: $Date: 2008-03-07 19:14:33 $ * par : $Author: thimel $ */ @@ -314,7 +314,7 @@ } protected void generateHibernateOneToMany(Writer output, ObjectModelAttribute attr) throws IOException { - boolean isIndexed = attr.isIndexed(); + boolean needsIndex = attr.isIndexed(); boolean isInverse = attr.getReverseAttribute().isNavigable(); isInverse |= hasUnidirectionalRelationOnAbstractType(attr, model); String orderBy = attr.getTagValue("order-by"); @@ -343,7 +343,7 @@ lazy += "\""; String collType = GeneratorUtil.getNMultiplicityHibernateType(attr); - if (!isIndexed) { + if (!needsIndex) { /*{ <<%=collType%> name="<%=getName(attr)%>" <%=orderBy%> <%=((!isInverse)?"":"inverse=\"true\"")%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="true"> @@ -352,7 +352,7 @@ }else { /*{ <<%=collType%> name="<%=getName(attr)%>"<%=((!isInverse)?"":" inverse=\"true\"")%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="false"> - + > }*/ @@ -360,13 +360,13 @@ } protected void generateHibernateMany(Writer output, ObjectModelAttribute attr) throws IOException { - boolean isIndexed = attr.isIndexed(); + boolean needsIndex = attr.isIndexed(); String collType = GeneratorUtil.getNMultiplicityHibernateType(attr); /*{ <<%=collType%> name="<%=getName(attr)%>" node="<%=getName(attr)%>" embed-xml="true"> }*/ - if (isIndexed) { -/*{ + if (needsIndex) { +/*{ }*/ } /*{ @@ -409,7 +409,7 @@ boolean isInverse = attr.isNavigable() && attr.getReverseAttribute().isNavigable(); isInverse |= !Util.isFirstAttribute(attr); isInverse = false; // 20070117 poussin: pour du many, jamais de inverse - boolean isIndexed = attr.isIndexed(); + boolean needsIndex = attr.isIndexed(); String cascade = ""; if (attr.isComposite() || attr.hasAssociationClass()) { cascade += "cascade=\"delete,delete-orphan\""; @@ -429,8 +429,8 @@ /*{ <<%=collType%> name="<%=getName(attr)%>" table="<%=GeneratorUtil.getManyToManyTableName(attr)%>" <%=(isInverse?"inverse=\"true\" ":"")%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="true"> }*/ - if (isIndexed) { -/*{ + if (needsIndex) { +/*{ }*/ } /*{