Hi!!
thanks for ask!!
I tried this.. delete-orphan works!! but I found new some problems...
When I edit a Persona Hibernate tries to insert a new Cliente causing PK constraint violation...
How I can do for Hibernate update the current Cliente and don't try to insert a new Cliente??
part of mapping code is
in Persona.hbm
Code:
<class name="model.Persona" table="persona" schema="public">
<id name="id" type="long">
<column name="id" />
<generator class="sequence">
<param name="sequence">persona_id_seq</param>
</generator>
</id>
in Cliente.hbm
Code:
<class name="model.Cliente" table="cliente" schema="public">
<id name="id" type="long">
<column name="id" />
<generator class="foreign">
<param name="property">persona</param>
</generator>
</id>
<one-to-one name="persona" constrained="true" />
the behaviour that i want is:
On inserts... (new objects to persist)
When I set a cliente in persona (persona.setCliente(cliente)) Hibernates insert a row in Clientes table... is i don't set cliente... Hibernate inserts nothing..
On Deletes
Hiberte deletes the cliente asociated to persona... In other word when I remove a persona hibernate removes the cliente asociated in cascade... (if cliente exists)
On Edit an existent persona...
If I edit a existent persona and I Change cliente's attribute descripcion (persona.getCliente().setDescripcion("hello");) i want that Hibernate persist this change on my database... (sql update sentence)
but... when I set null the cliente on an existent persona (persona.setCliente(null);) I WANT HIBERNATE REMOVE THE CLIENTE OF MY DATABASE.