我有一個插入查詢與其他字段一起插入Timestamp。現在無論何時,Timestamp的值爲空,我得到的錯誤 -java.sql.SQLException:ORA-00932:數據類型不一致:預期DATE在插入空時戳時得到了BINARY
java.sql.SQLException: ORA-00932: inconsistent datatypes: expected DATE got BINARY
我使用的是oracle 11g。
查詢是:
@Modifying
@Query(value ="INSERT INTO mams_asset a (a.mams_asset_id, a.mams_folder_id, a.asset_name, a.gist, a.last_modified_date, a.last_exported_date, a.created_date) VALUES (hextoraw(?1), hextoraw(?2), ?3, ?4, ?5, ?6 , ?7)" , nativeQuery = true)
int insertIntoMamsAsset(String mamsAssetId, String mamsFolderId, String assetName, String gist, Timestamp lastModifiedDate, Timestamp lastExportedDate, Timestamp createdDate);
這是雖然彈簧數據JPA之一。我試圖用這種方法太多,但同樣的錯誤:
public int insertIntoMamsAsset(String mamsAssetId, String mamsFolderId, String assetName, String gist, Timestamp lastModifiedDate, Timestamp lastExportedDate, Timestamp createdDate){
final Query query = entityManager.createNativeQuery("INSERT INTO mams_asset a (a.mams_asset_id, a.mams_folder_id, a.asset_name, a.gist, a.last_modified_date, a.last_exported_date, a.created_date) VALUES (hextoraw(?), hextoraw(?), ?, ?, ?, ? , ?)")
.setParameter(1, mamsAssetId)
.setParameter(2,mamsFolderId)
.setParameter(3,assetName)
.setParameter(4,gist)
.setParameter(5,lastModifiedDate)
.setParameter(6,lastExportedDate)
.setParameter(7,createdDate);
return query.executeUpdate();
}
雖然查詢似乎長,但你可以只專注於時間戳字段,這就是正在產生錯誤。
這是什麼工作?