Here are my hibernate mappings:
The error I get is that Hibernate generates the following prepared statement:
insert into MEDIA (PERSON_ID, FILE_TYPE, FILE_LOCATION, ORDER_NUM, TITLE, person_id, file_id) values (?, ?, ?, ?, ?, ?, ?)
Notice how PERSON_ID appears twice
I changed it so PERSON_ID to be upper case in all places. Hibernate just falls over at the point of loading its XML files then.
i tried insert="false". Hibernate does not like this either. In fact I get a message before I even compile
Attribute "insert" must be declared for element type "one-to- many".
I am using Hibernate 3.3.1
Please help I have this error for the last few days and no matter what i do I cant fix it
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">
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