【发布时间】:2011-11-17 22:49:23
【问题描述】:
我在保存域类对象时收到“ORA-00972:标识符太长”错误。
Caused by: org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.intelligrape.model.Address.studentsForPermanentAddressId#79366215]
除了减少studentsForPermanentAddressId 字段的长度之外,还有什么可能的解决方案来解决这个问题。原因是,这是一个我无法更改的遗留数据库表。
编辑:按照 Rob Hruska 的要求添加了域类描述
package com.intelligrape.model
class Address {
String address1
String address2
String boxNumber
String city
Long stateLid
String province
String zipCode
Long countryLid
Double latitude
Double longitude
Long radius
static hasMany = [studentsForPermanentAddressId: Student, studentsForLocalAddressId: Student]
static constraints = {
address1 nullable: true
address2 nullable: true
boxNumber nullable: true, size: 1..25
city nullable: true, size: 1..30
stateLid nullable: true
province nullable: true, size: 1..64
zipCode nullable: true, size: 1..15
countryLid nullable: true
latitude nullable: true
longitude nullable: true
radius nullable: true
studentsForPermanentAddressId nullable: true
studentsForLocalAddressId nullable: true
}
}
【问题讨论】:
-
有意思,Oracle 的长度限制是 30,而
studentsForPermanentAddressId"only" 有 29 个字符。 -
@NullUserException - 我不认为
studentsForPermanentAddressId是实际数据库列的名称;它可能映射到students_for_permanent_...之类的东西。 -
@Mohd - 您能否提供定义相关关系的域类代码?
-
伙计们,我已经通过 grails 邮件列表得到了这个问题的答案。请检查。 grails.1312388.n4.nabble.com/…
-
NullUser,Hibernate 有时会生成带有一些非常丑陋的连接和别名的 sql,所以如果你是 29 岁,30 岁时生成别名并不难,所以即使他使用默认命名和列名是studentsForPermanentAddressId,例如可以生成带有_studentsForPermanentAddressId0的sql。
标签: oracle hibernate grails grails-orm