1 回答

TA貢獻1858條經驗 獲得超8個贊
目前,Envers 不支持在可嵌入對象中嵌套嵌入對象的想法,當我們映射標識符列時,如您的示例所示。Envers 目前支持的唯一有效映射是可嵌入對象中的屬性是 a 或 類型。@ManyToOne@Basic
您可以解決此問題,但它涉及更明確一點,而不是使用。我的意思是重寫如下:RecordIdBlocRecordId
@Embeddable
public class BlocRecordId implements Serializable {
@Column(name = "identifier_")
String identifier;
@Column(name = "recordType_")
String recordType;
@Column(name = "source_")
String source;
@Column(name = "messageType_")
String messageType;
@Transient
private RecordId recordId;
/** Helper method to assign the values from an existing RecordId */
public void setRecordId(RecordId recordId) {
this.identifier = recordId.getIdentifier();
this.recordType = recordId.getRecordType();
}
/** Helper method to get the RecordId, caching it to avoid multiple allocations */
public RecordId getRecordId() {
if ( recordId == null ) {
this.recordId = new RecordId( identifier, recordType );
}
return this.recordId;
}
}
我同意這并不理想,但它至少可以解決代碼的當前限制。我已經添加并添加了HHH-13361作為開放問題來支持這一點。如果您愿意,歡迎您做出貢獻,或者我將努力為Envers 6.0提供此支持。
添加回答
舉報