gpt4 book ai didi

grails - 在Grails中使用数据库 View

转载 作者:行者123 更新时间:2023-12-02 15:42:29 24 4
gpt4 key购买 nike

我已经在数据库Postgres中创建了一个 View 。在grails中创建一个类,如下所示:

class ViewDeudce{

BigDecimal stateid
BigDecimal motivid

static mapping = {
id column:"id", sqlType:"numeric"
table 'viewDeudce'
version false
}
}

View 的ID是“客户编号”。如果我有一个“Client”类,那么在执行此操作时,我应该不能将其关联?:
class Clients implements Serializable {

String name
BigDecimal document
String brutos

ViewDeudce viewDeudce

static mapping = {
id column:"idclient", sqlType:"numeric", generator: 'assigned'
ViewDeudce column: "id", sqlType:"numeric"
version false
}

据我了解,我不是通过id属性告诉Client类与'ViewDeudce'类相关吗?

因为重新启动服务器时,它不会启动我,并且给我以下错误:
Caused by BeanCreationException: Error creating bean with name '$ primaryTransactionManager': Can not resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' sessionFactory ': Invocation of init method failed; nested exception is org.hibernate.HibernateException: Missing column: id in public.clients
- >> 266 | run in java.util.concurrent.FutureTask

谢谢!

最佳答案

也许尝试使用id而不是grails.domain类

class Clients implements Serializable {

String name
BigDecimal document
String brutos

//ViewDeudce viewDeudce
//!!change here!!
Long viewDeudceId

static mapping = {
id column:"idclient", sqlType:"numeric", generator: 'assigned'
ViewDeudce column: "id", sqlType:"numeric"
version false
}

关于grails - 在Grails中使用数据库 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55574194/

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