Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-11089

Naming Strategy Does not affect the user-specified index/foreign-key names

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.9
    • Fix Version/s: 5.2.9
    • Component/s: None
    • Labels:
      None
    • Environment:
      ubuntu, oracle 12c

      Description

      Hello,

      I have the following entity:

      @Entity
      @Table(uniqueConstraints = @UniqueConstraint(name = "my_longer_than_30_symbols_name", columnNames = { "category_pk", "id" }))
      public class ProductEntity {
      
      }
      

      Now it all works good with Mysql and PostgreSQL but Oracle has this limit about 30 characters for columns, tables, indexes, foreign keys, etc. I tried specifying my own OraclePhysicalNamingStrategy and OracleImplicitNamingStrategy and the @UniqueConstraint's name is passed to my strategy so I can shrink it - BUT ONLY if I haven't specified explicit name.

      The problem now is I have a platform with ~ 200 entities and relations where I have specified index names everywhere and I can't just delete them.

      The same thing happens with @JoinColumn and @ForeignKey. As soon as I specify name for the foreign key it is no longer passed to the naming strategy so I cannot shrink it. But If I leave it like this:

      @JoinColumn(foreignKey = @ForeignKey)
      

      then it is auto-generated and it is passed to the naming strategy where I can shrink it.

      The discussion about this issue is here:

      http://stackoverflow.com/questions/38565495/how-to-handle-the-ora-00972-identifier-is-too-long-exception-with-hibernate-5-a/

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: