gpt4 book ai didi

hibernate - 如何从Grails的数据库 View 创建域

转载 作者:行者123 更新时间:2023-12-02 14:41:02 25 4
gpt4 key购买 nike

我试图从数据库 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 = {
}
}

我使用oracle 10g,并在 View 中使用到另一个oracle数据库的链接。

View :
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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com