I've got a class Aplicacion:

public class Aplicacion {

    private Integer id;

    private String nombre;

    private Usuario funcional = new Usuario();

    private Usuario tecnico = new Usuario();

    ...

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }    

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }


    public Usuario getFuncional() {
        return funcional;
    }

    public void setFuncional(Usuario funcional) {
        this.funcional = funcional;
    }

    public Usuario getTecnico() {
        return tecnico;
    }

    public void setTecnico(Usuario tecnico) {
        this.tecnico = tecnico;
    }

    ...

}

and the class Usuario:

public class Usuario {

    private Integer id;

    private String nombre;

    ...

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    ...

}

The hibernate mapping for Aplicacion is:

<hibernate-mapping>

        <class name="es.gva.san.jguiri.persistencia.Aplicacion" 
table="APLICACION">

                <id name="id" unsaved-value="-1">
                        <generator class="sequence">
                                aplicacion_id_seq
                        </generator>
                </id>

                <property name="nombre" />

                ...

                <many-to-one name="funcional" column="FK_FUNCIONAL" />
                <many-to-one name="tecnico" column="FK_TECNICO" />

        </class>
</hibernate-mapping>

and hibernate mapping for Usuario is:

<hibernate-mapping>

        <class name="es.gva.san.jguiri.persistencia.Usuario" table="USUARIO">

                <id name="id" unsaved-value="-1">
                        <generator class="sequence">
                                usuario_id_seq
                        </generator>
                </id>

                <property name="nombre" />

                ...


        </class>
</hibernate-mapping>

The JSP page is like that:

...

<html:text property="aplicacion.funcional.id"></html:text>

...

<html:text property="aplicacion.tecnico.id"></html:text>

...

The form is a DynaValidatorForm with a property of type Aplicacion.

The action is:

public ActionForward guardar(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        DynaActionForm dynaForm = (DynaActionForm) form;

        Aplicacion aplicacion = (Aplicacion) dynaForm.get("aplicacion");

        HibernateUtil.saveOrUpdate(aplicacion);

        return unspecified(mapping, form, request, response);
        
}

The class Usuario is a table with different persons. The class Aplicacion is
associated with Usuario two times. One time through “tecnico” and another
time through “funcional”.

When I select a Usuario for “tecnico” associaton and another different
Usuario for “funcional” associaton and save there is no problem. When I
select the same Usuario for “tecnico” and “funcional” and save it seems not
to be a problem, but when next I select again a different Usuario for
“tecnico” and for “funcional” and save… the “tecnico” and “functional” are
the same, and allways the value of the “tecnico” (the last <html:text>)

I’m very confused and I have tried a lot of things (inherit “tecnico” and
“funcional” from “Usuario”, using a diferent type of Form, …) and I have
found no solution. Please, can anyone help me?
-- 
View this message in context: 
http://www.nabble.com/Problem-with-multiple-associatons-between-2-classes-tf4441448.html#a12672100
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to