Index: topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java diff -u topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.3 topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.4 --- topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.3 Fri Jan 6 18:38:34 2006 +++ topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java Mon Jan 9 19:31:44 2006 @@ -24,9 +24,9 @@ * Created: 12 déc. 2005 * * @author Arnaud Thimel -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * -* Mise a jour: $Date: 2006/01/06 18:38:34 $ +* Mise a jour: $Date: 2006/01/09 19:31:44 $ * par : $Author: thimel $ */ @@ -179,12 +179,12 @@ } private void generateHibernateOneToOne(Writer output, ObjectModelAttribute attr, boolean isAssoc) throws IOException { -/*{ /> +/*{ <%=(attr.isComposite()?" cascade=\"delete\"":"")%>/> }*/ } private void generateHibernateOneToMany(Writer output, ObjectModelAttribute attr, boolean isAssoc) throws IOException { -/*{ +/*{ > Index: topia2/src/java/org/codelutin/topia/generator/DAOAbstractGenerator.java diff -u topia2/src/java/org/codelutin/topia/generator/DAOAbstractGenerator.java:1.2 topia2/src/java/org/codelutin/topia/generator/DAOAbstractGenerator.java:1.3 --- topia2/src/java/org/codelutin/topia/generator/DAOAbstractGenerator.java:1.2 Wed Jan 4 13:21:51 2006 +++ topia2/src/java/org/codelutin/topia/generator/DAOAbstractGenerator.java Mon Jan 9 19:31:44 2006 @@ -24,10 +24,10 @@ * Created: 12 déc. 2005 * * @author Arnaud Thimel -* @version $Revision: 1.2 $ +* @version $Revision: 1.3 $ * -* Mise a jour: $Date: 2006/01/04 13:21:51 $ -* par : $Author: bpoussin $ +* Mise a jour: $Date: 2006/01/09 19:31:44 $ +* par : $Author: thimel $ */ package org.codelutin.topia.generator; @@ -40,6 +40,7 @@ import org.codelutin.generator.Generator; import org.codelutin.generator.ObjectModelGenerator; import org.codelutin.generator.Util; +import org.codelutin.generator.models.object.ObjectModelAssociationClass; import org.codelutin.generator.models.object.ObjectModelAttribute; import org.codelutin.generator.models.object.ObjectModelClass; import org.codelutin.generator.models.object.ObjectModelClassifier; @@ -105,17 +106,37 @@ *) }*/ if (!Util.isNMultiplicity(attr)) { - generateNoNMultiplicity(output, attr); + generateNoNMultiplicity(output, attr, false); } else { - generateNMultiplicity(output, attr); + generateNMultiplicity(output, attr, false); + } + } + + if (clazz instanceof ObjectModelAssociationClass) { + ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz; + Iterator it = assocClass.getParticipantsAttributes().iterator(); + while (it.hasNext()) { + ObjectModelAttribute attr = (ObjectModelAttribute)it.next(); + if (attr != null) { + if (!Util.isNMultiplicity(attr)) { + generateNoNMultiplicity(output, attr, true); + } else { + generateNMultiplicity(output, attr, true); + } + } } } -/*{} //<%=clazz.getName()%>DAOAbstract +/*{ +} //<%=clazz.getName()%>DAOAbstract }*/ } - protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr) throws IOException { + protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, boolean isAssoc) throws IOException { + String propertyName = attr.getName(); + if (!isAssoc && attr.hasAssociationClass()) { + propertyName = GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName; + } /*{ /** * Retourne le premier élément trouvé ayant comme valeur pour l'attribut @@ -124,7 +145,7 @@ * @return un element ou null *) public E findBy<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException { - E result = getParentDAO().findByProperty("<%=attr.getName()%>", v); + E result = getParentDAO().findByProperty("<%=propertyName%>", v); return result; } /** @@ -134,13 +155,37 @@ * @return une liste *) public List findAllBy<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException { - List result = getParentDAO().findAllByProperty("<%=attr.getName()%>", v); + List result = getParentDAO().findAllByProperty("<%=propertyName%>", v); + return result; + } +}*/ + if (attr.hasAssociationClass()) { +/*{ + /** + * Retourne le premier élément trouvé ayant comme valeur pour l'attribut + * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramètre + * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> + * @return un element ou null + *) + public E findBy<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException { + E result = getParentDAO().findByProperty("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>", value); + return result; + } + /** + * Retourne les éléments ayant comme valeur pour l'attribut + * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramètre + * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> + * @return une liste + *) + public List findAllBy<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException { + List result = getParentDAO().findAllByProperty("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>", value); return result; } }*/ + } } - protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr) throws IOException { + protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, boolean isAssoc) throws IOException { /*{ /** * Retourne le premier élément trouvé dont l'attribut