我在我的DB Postgres中创建了一个视图。在grails中创建一个类,如下所示:
class ViewDeudce{
BigDecimal stateid
BigDecimal motivid
static mapping = {
id column:"id", sqlType:"numeric"
table 'viewDeudce'
version false
}
}
视图的ID是“客户端编号”。如果我有一个“客户”课程,那么在做这个时,我应该无法联系到它?:
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来reated而不是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
}