Hi,
I have a composite primary key for a DB2 table. So, I have the following java classes with Hibernate annotations:
@Entity @IdClass(LocationModelPK.class) @Table(name = "T074AT63") LocationModel.java { private LocationModelPK idPK;
private String organization; private String ccpl; private String processArea;
@Column(name = "CLM_INVT_LOC_CODE", nullable = false, length = 3) private String inventoryLocation;
@Column(name = "SCY_RCP_LGN_ID", nullable = false, length = 8) private String userId;
@Column(name = "RCD_MNT_TSP_GRP", nullable = false, length = 26) private Timestamp lastUpdate;
public Object getId() { return this.idPK; }
...... getters and setters for these attributes, equals() and hashCode() }
@Embeddable LocationModelPK.java { @Column(name = "CLM_PCS_ORG_CODE", nullable = false, length = 6) private String organization; @Column(name = "CLM_PCS_LOC_CODE", nullable = false, length = 3) private String ccpl; @Column(name = "CLM_PCS_ARA_CODE", nullable = false, length = 4) private String processArea;
public Object getId() { return null; }
....... getters and setters, equals() and hashCode() }
When I try to save a record for this model class to the database (DB2 V8 with a Type 2 Driver), I get the following error :
COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0612E Invalid parameter number. SQLSTATE=S1093 at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throwParamIndexError(SQLExceptionGenerator.java:620) at COM.ibm.db2.jdbc.app.DB2PreparedStatement.setNull(DB2PreparedStatement.java:2258) at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.setNull(WSJdbcPreparedStatement.java:1485)
I think it is trying to pick up "idPK" as an attribute to be saved along with the other attributes.
Any help is greatly appreciated.
Regards, Yogesh
|