Hi,
I'm trying a very simple insert of an object and I'm noticing that the ID of the object is not being set in my pojo after the call to save. I thought that hibernate was supposed to set the ID after the object is persisted? Am I wrong in my understanding?
As a result, my subsequent code which needs the object id is not going through. I'm getting below error because of this issue.
Since the id is not returned after save, the default value for long which is 0 is set for further code, as result am getting foreign key violation because the parent table doesnt contain a record with key value as 0.
Caused by: java.sql.SQLException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_PROV_SET_ASSOC_PROV_PID". The conflict occurred in database "alineo", table "PROVIDER.PROVIDER", column 'PROVIDER_PID'. at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365) at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781) at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224) at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628) at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:525) at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:487) at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:421) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
Mapping file : ------------
the id details in the mapping file.
<id name="pid" type="long" column="CUSTOMER_PID"> <generator class="native"> <param name="sequence">CUSTOMER.SQ_CUSTOMER</param> </generator> </id>
|