2
我正在使用Hibernate註釋和Sybase。我正在設置一個版本列以防止鎖定。數據庫需要管理時間戳而不是應用程序。我想用註釋而不是hbm.xml來完成。由數據庫控制的休眠時間戳版本。
我已經嘗試沒有成功以下,
我讀jboss.org使用
@org.hibernate.annotations.SourceType.DB
@org.hibernate.annotations.Generated(GenerationTime.ALWAYS)
但是我發現了一個IDE編譯錯誤DB, 「找不到符號 符號:類DB 位置:類SourceType中」
和rowVersion一個編譯錯誤,
Version字段或屬性不是支持的類型之一。確保它是以下類型之一:int,Integer,short,Short,long,Long,java.sql.Timestamp。
時間屬性必須用@Temporal註解標記。
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/mapping.html#d0e5785
5.1.3.2。時間戳
示例代碼
@Version
@org.hibernate.annotations.SourceType.DB
@org.hibernate.annotations.Generated(GenerationTime.ALWAYS)
@Column(name = "row_version")
private Date rowVersion;
public Date getRowVersion() {
return rowVersion;
}
public void setRowVersion(Date rowVersion) {
this.rowVersion = rowVersion;
}
有人能告訴我,我缺少的是什麼?
謝謝,最後一個問題,你是如何處理日期數據類型。 IDE希望我使用必須使用時間註釋標記時域屬性 –
我應該使用什麼日期時間? –
只需將時間註釋添加到該字段即可。 (例如版本) – Markus