我有mysql视图与组合多个表列。我只想从这个视图中选择数据来在html页面中显示网页。不需要使用GORM创建/更新/删除。我如何定义这个视图的域类?
我的看法是这样的。
view name: testview
col1 int,
col2 varchat(50),
col3 date谢谢
发布于 2013-01-04 11:21:16
假设col1是主键:
class View {
Integer col1
String col2
Date col3
static mapping = {
table name: "testview"
version false
id name: "col1", generator: "assigned"
// These are unnecessary unless you change the name of the fields
col1 column: "col1"
col2 column: "col2"
col3 column: "col3"
}
}发布于 2013-01-04 11:32:57
Grails gorm不提供对视图的直接访问,但是您可以尝试使用HQL,或者参考Elegant ways to handle database views on hibernate entities?。
https://stackoverflow.com/questions/14150467
复制相似问题