Does overloading Grails static 'mapping' property to bolt on database objects violate DRY?

Posted by mikesalera on Stack Overflow See other posts from Stack Overflow or by mikesalera
Published on 2010-04-02T00:44:19Z Indexed on 2010/04/02 0:53 UTC
Read the original article Hit count: 386

Does Grails static 'mapping' property in Domain classes violate DRY? Let's take a look at the canonical domain class:

class Book {
     Long id
     String title
     String isbn
     Date published
     Author author
     static mapping = {
            id generator:'hilo', params:[table:'hi_value',column:'next_value',max_lo:100]
     }
}

or:

class Book { ...
        static mapping = {
            id( generator:'sequence', params:[sequence_name: "book_seq"] )
    }
}

And let us say, continuing this thought, that I have my Grails application working with HSQLDB or MySQL, but the IT department says I must use a commercial software package (written by a large corp in Redwood Shores, Calif.).

Does this change make my web application nobbled in development and test environments? MySQL supports autoincrement on a primary key column but does support sequence objects, for example.

Is there a cleaner way to implement this sort of 'only when in production mode' without loading up the domain class?

© Stack Overflow or respective owner

Related posts about grails

Related posts about hibernate