gpt4 book ai didi

grails - Grails从2.4.5升级到3.3.2:关系 'xxx'不存在

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

是否需要进行数据库迁移才能将Grails 2.4.5升级到3.3.2项目。当前,我在Bootstrap.groovy中遇到问题,应用程序无法启动。

ERROR: Relation "department" does not exist

org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not execute statement; bad SQL grammar [n/a]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "department" does not exist
Position: 13
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.grails.orm.hibernate.GrailsHibernateTemplate.convertJdbcAccessException(GrailsHibernateTemplate.java:731)
at org.grails.orm.hibernate.GrailsHibernateTemplate.convertHibernateAccessException(GrailsHibernateTemplate.java:719)
at org.grails.orm.hibernate.GrailsHibernateTemplate.doExecute(GrailsHibernateTemplate.java:303)
at org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:243)
at org.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:117)
at org.grails.orm.hibernate.AbstractHibernateGormInstanceApi.performSave(AbstractHibernateGormInstanceApi.groovy:242)
at org.grails.orm.hibernate.AbstractHibernateGormInstanceApi.save(AbstractHibernateGormInstanceApi.groovy:159)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:151)
at org.grails.datastore.gorm.GormEntity$Trait$Helper$save.call(Unknown Source)
at vaparigrails.Company.save(Company.groovy)
at vaparigrails.Company.save(Company.groovy)

关于问题的任何想法。提前致谢!

编辑:
部门标签:
class DepartmentTag {
String name
String details
static constraints = {
}
static belongsTo = [department : Department]
}

部门域类:
class Department {
String name
String address
String postalCode=''
String phoneNumber=''
String email=''
String homeCounty=''
Float latitude
Float longitude
List speciality

static constraints = {
homeCounty defaultValue: 'XXX'
email nullable:true, defaultValue: ''
phoneNumber nullable:true
address nullable:true
postalCode nullable:true
homeCounty nullable:true
latitude nullable:true, scale:6
longitude nullable:true, scale:6
speciality nullable: true
}
static mapping = {
vacancy lazy: false
}

static belongsTo = [company: Company]

static hasMany = [ speciality: String, tags : DepartmentTag, comments:Comment, phoneContacts:PhoneContact, ipAddresses: IPAddress]
static hasOne = [ vacancy : Vacancy ]

Bootstrap.groovy

类BootStrap {
def init = { servletContext ->
// Check whether the test data already exists.
def openTag = new DepartmentTag(name:"name1", details:"details1").save(failOnError:true)
def terTag = new DepartmentTag(name:"name2", details:"details2").save(failOnError:true)
}
if(!Company.count()) {
new Company(name: "company1", phoneNumber: "+12345", address: "address1", postalCode: "12345", email: "testi@testi.com", homeCounty: "XXX").save(failOnError: true)
.addToDepartment(new Department(name: "department_name", speciality: ["speciality1", "speciality2"], address: "address1", postalCode: "12345", homeCounty: "XXX", phoneNumber: "12345", email: "testi@testi.com", vacancy: new Vacancy(maleVacancy: 4, femaleVacancy: 4, specialVacancy: 2)).addToTags(terTag)).save(failOnError: true)

公司域名类别:
    class Company {
String name
String phoneNumber=''
String address
String postalCode=''
String email=''
String homeCounty=''

static constraints = {
email nullable:true, defaultValue: ''
phoneNumber nullable:true
address nullable:true
postalCode nullable:true
homeCounty nullable:true
}
static hasMany = [department: Department,users : WebUser]
}

最佳答案

大概您同时从Hibernate 4更新到了5? Hibernate 5当前存在一个问题,即它以不同方式生成外键:https://hibernate.atlassian.net/browse/HHH-10574

我不确定这是您遇到的问题,但可能与它有关。即使没有,也要注意。

关于grails - Grails从2.4.5升级到3.3.2:关系 'xxx'不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48948690/

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