Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2 final
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 9.10, Oracle 10g

      Description

      I am currently seeing a problem with custom sequence mappings in GORM. They appear to just be ignored - not created in schema-export (except default hibernate_sequence and as far as I can see Grails just ignores them and uses the hibernate one (at least it is consistent).

      I'm not sure if this is a GORM thing or Hibernate thing, but haven't seen any other posts on it. As far as I can see the problem does not appear on Grails 1.1, haven't tried it on any other databases... I'll try Mysql later.

      Here is my current Mapping code in Config.groovy:

      grails.gorm.default.mapping = {
          id generator: 'native'
      }
      

      (also tried sequence 'sequence' with same result)

      and on each domain class something like this:

      id column: 'REPOSITORY_ID', params:[sequence:'SEQ_TEIMR_REPOSITORY']
      

        Activity

        Hide
        Burt Beckwith added a comment -

        I'll look and see if it's straightforward to implement but in the meantime you can create a custom dialect. See this thread for a Postgres example: http://n4.nabble.com/One-hibernate-sequence-is-used-for-all-Postgres-tables-td1351722.html

        The Oracle version is nearly identical; I originally wrote it for Oracle but converted to Postgres for that email. You'll need to subclass whatever Oracle dialect you're using now instead of PostgreSQLDialect, and change the table-to-sequence naming logic.

        Show
        Burt Beckwith added a comment - I'll look and see if it's straightforward to implement but in the meantime you can create a custom dialect. See this thread for a Postgres example: http://n4.nabble.com/One-hibernate-sequence-is-used-for-all-Postgres-tables-td1351722.html The Oracle version is nearly identical; I originally wrote it for Oracle but converted to Postgres for that email. You'll need to subclass whatever Oracle dialect you're using now instead of PostgreSQLDialect, and change the table-to-sequence naming logic.
        Hide
        Steve Dalton added a comment -

        Thanks Burt - yes I had considered that before as it gives me much more flexibility over foreign keys and other things. If it's just subclassing I might give that a go today.

        Show
        Steve Dalton added a comment - Thanks Burt - yes I had considered that before as it gives me much more flexibility over foreign keys and other things. If it's just subclassing I might give that a go today.
        Hide
        Steve Dalton added a comment -

        Just tried Burt's workaround and it works a treat, might actually use this solution long term anyway as we have quite a few other things we would like to customize to avoid a lot of the mapping we have to do in our domain objects to fit our DB naming standard.

        btw. If anyone needs to recreate the original problem but they don't have Oracle - you don't need to actually run against Oracle to recreate. Just get the Oracle JDBC driver and run a schema-export.

        Show
        Steve Dalton added a comment - Just tried Burt's workaround and it works a treat, might actually use this solution long term anyway as we have quite a few other things we would like to customize to avoid a lot of the mapping we have to do in our domain objects to fit our DB naming standard. btw. If anyone needs to recreate the original problem but they don't have Oracle - you don't need to actually run against Oracle to recreate. Just get the Oracle JDBC driver and run a schema-export.
        Hide
        Graeme Rocher added a comment -

        Burt since you volunteered to look into the problem I'm assigning to you

        Since there is a workaround feel free to downgrade to a minor issue

        Show
        Graeme Rocher added a comment - Burt since you volunteered to look into the problem I'm assigning to you Since there is a workaround feel free to downgrade to a minor issue
        Hide
        Burt Beckwith added a comment -

        Closing as Won't Fix since there's not much that can be done on the Grails side. The issue is in the Hibernate Dialect and it depends on the version of Oracle you're using so the custom dialect approach referenced in the comments is the workaround.

        Show
        Burt Beckwith added a comment - Closing as Won't Fix since there's not much that can be done on the Grails side. The issue is in the Hibernate Dialect and it depends on the version of Oracle you're using so the custom dialect approach referenced in the comments is the workaround.

          People

          • Assignee:
            Burt Beckwith
            Reporter:
            Steve Dalton
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development