Vincent,
I've got two properties because it's a web app. Basically, i can't keep the track of the 'related object' in an html form... i can keep only the ID.
When i modify something, i get setted the ID via web. I can't put a java-object in an html combo box.
The java code is really simple. This is from my class Cliente (Client):
Code:
public String update(){
HibernateUtil.update(this);
new Log((Map)ActionContext.getContext().get("session"),"Modificacion de Cliente [" + nombre +"]");
addActionMessage("Modificacion exitosa");
System.out.println("Empresa: " + e);
return SUCCESS;
}
And this is from HibernateUtil:
Code:
public static void update(Object o){
HibernateUtil.beginTransaction();
Session session = HibernateUtil.getSession();
session.merge(o);
session.flush();
session.refresh(o);
}
If i load an object, everything works fine. The proxy gets instantiated and i can read the 'related object'.
But... when i update an object... because of the architecture of my framework (webwork), a whole new object gets instantiated, with the attributes sent by the client's browser. So, i get only 'idEmpresa'. I needed to 'refresh' the association because the hibernate-proxy gets lost on the way.
Thanks again Vincent..!!!
George