gpt4 book ai didi

grails - 如何解决 Grails Error Repeated column in mapping for entity?在现有的 Postgresql 数据库上

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

您好,我在 Grails 中有以下域

class Customer {    static mapping = {         table 'customer'         // version is set to false, because this isn't available by default for legacy databases         version false         id column:'customerid' //generator:'identity',     }    Long customerid    Long customergroupid    String username    String password    String name    String street    String city    String province    String postcode    String country    Date dateregistered    String balance    Long parentid    String parentrebate    String metapath    Long metalevel    Integer smsreplystatus    Integer status    String reversalurl    static constraints = {        customerid(insert:false,update:false)        customergroupid(max: 9999999999L)        username(size: 1..20, blank: false)        password(size: 1..32, blank: false)        name(size: 1..20, blank: false)        street(size: 0..50)        city(size: 0..20)        province(size: 0..20)        postcode(size: 0..5)        country(size: 0..20)        dateregistered(nullable: true)        balance()        parentid(max: 9999999999L)        parentrebate()        metapath(size: 1..255, blank: false)        metalevel(max: 9999999999L)        smsreplystatus(max: 99999)        status(max: 99999)        reversalurl(size: 0..50)    }    String toString() {        return "${customerid}"     }}

我有包含现有数据的当前数据库,并已使用 GRAG 映射到 GORM,但我收到此错误

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot 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.MappingException: Repeated column in mapping for entity: postgresql.Customer column: customerid (should be mapped with insert="false" update="false")    ... 23 moreCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: postgresql.Customer column: customerid (should be mapped with insert="false" update="false")

最佳答案

有同样的问题,删除“Long customerid”

这可能不是一个可行的解决方案,但至少应用会编译并创建表格。

根本没有调查,因为我只是设法让它工作——也许在设置自定义标识列时,隐含了属性定义(因此出现“重复列...”错误)

关于grails - 如何解决 Grails Error Repeated column in mapping for entity?在现有的 Postgresql 数据库上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4457727/

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