我正在尝试使用一对一映射创建一对GORM域对象,但需要注意的是两个表之间的键不是很长,而是UUID字符串/ varchar.我一直在寻找关于如何在grails/gorm中执行此操作的讨论,并找到了一些问题,但没有使用答案.这是我的两个班级,我希望有人能指出我合理的方向.
谢谢.
class ItemLastChange {
static belongsTo = [item: Item]
static mapping = {
cache true
version false
id column: 'item_hash_msb', name: 'itemHashMsb'
item column: 'item_uuid', key: 'uuid', sqlType: 'text', type: 'text', insertable: false, updateable: false
}
static constraints = {
}
long itemHashMsb;
String itemUuid;
String itemMapCode;
String dbActionType;
String version;
Calendar modificationDate;
}
class Item {
static hasOne = [itemLastChange: ItemLastChange]
static mapping = {
cache true
version false
id column:'item_id'
columns {
itemLastChange column: 'uuid', lazy: …Run Code Online (Sandbox Code Playgroud)