ORA-00972:标识符太长 - 在Grails中避免使用它的最佳策略

Moh*_*rid 9 oracle grails hibernate grails-orm

保存域类对象时,我收到"ORA-00972:标识符太长"错误.

Caused by: org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.intelligrape.model.Address.studentsForPermanentAddressId#79366215]
Run Code Online (Sandbox Code Playgroud)

除了减少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
    }
}
Run Code Online (Sandbox Code Playgroud)

Rob*_*ner 5

添加映射块和现有列映射:

    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 mappings = {
         studentsForPermanentAddressId(column: 'stud_perm_addr_id')
    }
    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
    }
}
Run Code Online (Sandbox Code Playgroud)

顺便说一句,如果这不是遗留数据库,您可以使用此项目:http://code.google.com/p/hibernate-naming-strategy-for-oracle/

从一开始就生成正确的映射.