作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图从数据库 View 创建域类。但是当我尝试运行项目时,我看到:
Error | 2016-01-19 17:15:00,525 [Thread-11] ERROR spi.SqlExceptionHelper - ORA- 01702: a view is not appropriate here Error | 2016-01-19 17:15:00,526 [Thread-11] ERROR hbm2ddl.SchemaUpdate - HHH000299: Could not complete schema update
class Branch {
int id
String name
static mapping = {
table 'smart_branch'
version false
cache: 'read-only'
id column: 'id'
name column: 'name'
}
static constraints = {
}
}
create or replace view branch (id, name) as (select id, convert(zzz.convert2@b(name)) from zzz.branch@db emp)
最佳答案
域类是一个实体,是db内部的一个表,可以在其上运行DML查询。 View 主要用于仅获取数据而不修改数据。
您也不应该尝试这样做。同样,如果您正在使用Hibernate为您生成模式,那么您将无法使用同名的表和 View 。您必须将dbCreate
中的none
模式设置为DataSource.groovy
,或者使用mapWith
属性从数据库中删除doamin的映射。
但是,如果您仍然想拥有一个从 View 中获取数据的Doamin类,则可以查看此answer。
关于hibernate - 如何从Grails的数据库 View 创建域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34878014/
我是一名优秀的程序员,十分优秀!