- the definition of the Domain Class
class Test {
//define id column as String type
String id
.....
//define the id generator type, it should use the manual assignment
static mapping={
id generator:'assigned'
}
} - using this domain class
def index = {
//create new object defined the primary key as the String type.
def test=new Test()
def date=new Date()
//set the unique value of primary key manually.
test.setId("pk-${date.getTime()}")
test.setMsg("Message")
//save
test.save()
...
}
2008年12月8日月曜日
[GRAILS]how to use the String type for the primary key column
How to use the String type primary key column in Domain Class on Grails environment.
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿