Ally Cavs wrote:<property name="person_id" column="PERSON_ID" type="string" insert="true" update="true"/>
in <class name="ie.gymlockr.admin.details.UploadedFile" table="MEDIA">
works
?
can someone explain what insert="true" update="true" do?
Ok, so for simplicity lets say I have an object
public class Person
with two properties
private Parent father
private int fatherId
Now both properties are the same relationship in the database, but I have both of those because of lets say legacy code already calls person.getFatherId()
but I want all my new code to call person.getFather().getFatherId();
and for Hibernate I need to store the fatherId into the person table. Well I don't want both associations to try and update the same FK field in the person table, so I have to state that one of the mapped properties be updatable="false" so hibernate does not include it in the update statement. Because it shouldn't show up in the update statement twice. Once for the fatherId property and once for the father associated Parent object.
The same thing happens with insertable="false" you are saying in insert statements not to include it.
Hope that helps clear things up
Mark