Does overloading Grails static 'mapping' property to bolt on database objects violate DRY?
- by mikesalera
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?