Index: topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java diff -u topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.17 topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.18 --- topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java:1.17 Tue Feb 28 17:20:07 2006 +++ topia2/src/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java Mon Mar 6 18:44:36 2006 @@ -24,10 +24,10 @@ * Created: 12 déc. 2005 * * @author Arnaud Thimel -* @version $Revision: 1.17 $ +* @version $Revision: 1.18 $ * -* Mise a jour: $Date: 2006/02/28 17:20:07 $ -* par : $Author: thimel $ +* Mise a jour: $Date: 2006/03/06 18:44:36 $ +* par : $Author: bpoussin $ */ package org.codelutin.topia.generator; @@ -64,6 +64,10 @@ private Map columnNamesMap = new HashMap(); + public EntityHibernateMappingGenerator() { + super(); + } + public EntityHibernateMappingGenerator(Generator parent) { super(parent); } @@ -135,13 +139,17 @@ for (Iterator i = assoc.getParticipantsAttributes().iterator(); i.hasNext(); ) { ObjectModelAttribute attr = (ObjectModelAttribute) i.next(); if (attr != null) { - if ((!attr.getReverseAttribute().isNavigable()) || !Util.isNMultiplicity(attr.getReverseAttribute())) { -/*{ <%=(attr.isComposite()?" cascade=\"delete\"":"")%>/> -}*/ - } else { + +// Note(poussin) pour moi quoi qu'il arrive sur la classe d'association il faut +// un many-to-one, sinon on a des problemes. +// if ((!attr.getReverseAttribute().isNavigable()) || !Util.isNMultiplicity(attr.getReverseAttribute())) { +// / *{ <%=(attr.isComposite()?" cascade=\"delete\"":"")%>/> +// } */ +// } else { + /*{ }*/ - } +// } //Ne sert plus grâce à l'utilisation de la navigabilité // if (!attr.getReverseAttribute().isNavigable()) { // String type = GeneratorUtil.getDOType(((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName(), model); @@ -239,16 +247,26 @@ protected void generateHibernateOneToMany(Writer output, ObjectModelAttribute attr) throws IOException { boolean isOrdered = attr.isOrdered(); boolean isInverse = attr.getReverseAttribute().isNavigable(); -/*{ <<%=(isOrdered?"list":"bag")%> name="<%=getName(attr)%>"<%=((!isInverse)?"":" inverse=\"true\"")%> lazy="true"<%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete,delete-orphan\"":"")%>> + String orderBy = attr.getTagValue("order-by"); + if (orderBy == null) { + orderBy = ""; + } else { + orderBy = "order-by=\"" + orderBy + "\""; + } + if (!isOrdered) { +/*{ <%=((!isInverse)?"":"inverse=\"true\"")%> lazy="true" <%=((attr.isComposite() || attr.hasAssociationClass())?"cascade=\"delete,delete-orphan\"":"")%>> + + }*/ - if (isOrdered) { -/*{ + }else { +/*{ lazy="true"<%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete,delete-orphan\"":"")%>> + + + + }*/ } -/*{ - > -}*/ } protected void generateHibernateMany(Writer output, ObjectModelAttribute attr) throws IOException { @@ -274,8 +292,10 @@ // On ne met le inverse="true" uniquement pour un seul coté de la relation. // Dans le cas contraire, les modifications dans la relation ne seront // pas sauvegardées + // Note(poussin) 20060306: pour moi il n'y a pas jamais d'inverse pour many-to-many + // car on est dans une table intermediaire specifique.<%=((!Util.isFirstAttribute(attr))?"inverse=\"true\" ":"")%> boolean isOrdered = attr.isOrdered(); -/*{ <<%=(isOrdered?"list":"bag")%> name="<%=getName(attr)%>" table="<%=getManyToManyTableName(attr)%>" <%=((!Util.isFirstAttribute(attr))?"inverse=\"true\" ":"")%>lazy="true"<%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete,delete-orphan\"":"")%>> +/*{ <<%=(isOrdered?"list":"bag")%> name="<%=getName(attr)%>" table="<%=getManyToManyTableName(attr)%>" lazy="true"<%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete,delete-orphan\"":"")%>> }*/ if (isOrdered) {