2011-09-15 13 views
9

Ricevo l'errore "ORA-00972: identificatore è troppo lungo" durante il salvataggio di un oggetto classe dominio.ORA-00972: l'identificatore è troppo lungo - La migliore strategia per evitarlo in Grails

Caused by: org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.intelligrape.model.Address.studentsForPermanentAddressId#79366215] 

Quali potrebbero essere le possibili soluzioni per risolvere questo problema, tranne riducendo la lunghezza del campo studentsForPermanentAddressId. Il motivo è che questa è una tabella di database legacy che non posso modificare.

EDIT: Aggiunta la descrizione della classe di dominio come chiesto da 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 
    } 
} 
+0

Questo è interessante, il limite di lunghezza di Oracle è 30 e 'studentsForPermanentAddressId'" solo "ha 29 caratteri. – NullUserException

+0

@NullUserException - Non penso che 'studentsForPermanentAddressId' sia il nome della colonna del database attuale; probabilmente sta mappando qualcosa come 'students_for_permanent _...'. –

+0

@Mohd: puoi fornire il codice della classe di dominio che definisce la relazione in questione? –

risposta

5

Aggiungi un blocco di mappatura e le mappature delle colonne esistenti:

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 
    } 
} 

Per inciso, se questo non fosse un database legacy è possibile utilizzare questo progetto: http://code.google.com/p/hibernate-naming-strategy-for-oracle/

Per generare mappature corrette dall'inizio.

Problemi correlati