oups! I've done a mistake. I had not deleted "mappedBy..." It's working fine now.
Thank you Michael. Julien. Michael Horwitz a écrit :
Could you post your modified annotations? On 8/24/07, *Julien C.* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: It's not better. Michael Horwitz a écrit :Try this from the Hibernate annotiations guide:To map a bidirectional one to many, with the one-to-many side asthe owning side, you have to remove the mappedBy element and set the many to one @JoinColumn as insertable and updatable to false. This solution is obviously not optimized and will produce some additional UPDATE statements. See section 2.2.5.3.2.1. here: http://tinyurl.com/ypdln3 Mike On 8/24/07, *Julien C.* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: I think it's correct : --------------------------------- @Entity public class Enquete implements java.io.Serializable { ... @OneToMany(mappedBy="enquete",cascade=CascadeType.ALL) public Set<Modele> getModeles() { return modeles; } ... } @Entity public class Modele implements java.io.Serializable { ... @ManyToOne @JoinColumn(name="ENQUETE_ID") public Enquete getEnquete() { return enquete; } ... } --------------------------------- Julien. Michael Horwitz a écrit : > Have you set the appropriate cascade on the relationship between > Enquete and Modele? > > Mike > > On 8/24/07, *Julien C.* < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote: > > Hi, > > I don't figure out how to use the form:select tag with multiple > select. I have try this : > > --------------------------------- > <form:select id="modeles" path="modeles" multiple="true" size="5" > > <c:forEach var="modele" items="${ enquete.modeles}"> > <form:option value="${ modele.id <http://modele.id/> <http://modele.id/>}" > label="${modele.nom}" /> > </c:forEach> > <form:options items="${modeles}" itemValue="id" > itemLabel="nom"></form:options> > </form:select> > --------------------------------- > no errors but nothing is selected and nothing is saved - > I have registered a custom binder for Modele object.. > > so I take a look to userForm (with roles) > I try this : > --------------------------------- > <form:select id="modeles" path="modeles" multiple="true" size="5" > > <c:forEach var="modele" items="${ enquete.modeles}"> > <option value="${modele.id <http://modele.id/> < http://modele.id/>}" > selected="selected" >${ modele.nom}</option> > </c:forEach> > <form:options items="${modeles}" itemValue="id" > itemLabel="nom"></form:options> > </form:select> > --------------------------------- > > and in my controller > --------------------------------- > ... > onSubmit{ > ... > String[] enqueteModeles = request.getParameterValues("modeles"); > if (enqueteModeles != null) { > log.debug("clearing enquete modeles"); > enquete.getModeles().clear(); > for (String modeleId : enqueteModeles) { > log.debug("adding modele " + modeleId); > enquete.getModeles().add( modeleManager.get( > Long.valueOf(modeleId)) ); > } > }else{ > log.debug("getParameterValues('modeles') is null"); > } > > enqueteManager.save (enquete); > ... > } > ... > --------------------------------- > It's working fine for the selection but nothing is saved : > It's strange because in my logs I've got : > > DEBUG [btpool0-1] EnqueteFormController.onSubmit (78) | clearing > enquete modeles > DEBUG [btpool0-1] EnqueteFormController.onSubmit(81) | adding modele 1 > DEBUG [btpool0-1] EnqueteFormController.onSubmit(81) | adding modele 2 > DEBUG [btpool0-1] EnqueteFormController.onSubmit (81) | adding > modele 3 > > So where is the problem ? > My Manager extends GenericManager... > > > A idea ? > Thanks, Julien Chanséaume. > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
