I am getting "ORA-00972: identifier is too long" error while saving a domain class object.
Caused by: org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.intelligrape.model.Address.studentsForPermanentAddressId#79366215]
What could be the possible solutions to solve this problem except reducing the length of studentsForPermanentAddressId field. The reason being, this is a legacy database table which I can not alter.
EDIT: Added the domain class description as asked by 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
}
}
Add a mapping block and the existing column mappings:
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
}
}
As an aside, if this weren't a legacy database you could use this project: http://code.google.com/p/hibernate-naming-strategy-for-oracle/
To generate correct mappings from the start.