How to force grails GORM to respect DB scheme ?
Posted
by fabien-barbier
on Stack Overflow
See other posts from Stack Overflow
or by fabien-barbier
Published on 2010-05-14T19:44:18Z
Indexed on
2010/05/14
21:24 UTC
Read the original article
Hit count: 311
I have two domains :
class CodeSet {
String id
String owner
String comments
String geneRLF
String systemAPF
static hasMany = [cartridges:Cartridge]
static constraints = {
id(unique:true,blank:false)
}
static mapping = {
table 'code_set'
version false
columns {
id column:'code_set_id', generator: 'assigned'
owner column:'owner'
comments column:'comments'
geneRLF column:'gene_rlf'
systemAPF column:'system_apf'
}
}
and :
class Cartridge {
String id
String code_set_id
Date runDate
static belongsTo = CodeSet
static constraints = {
id(unique:true,blank:false)
}
static mapping = {
table 'cartridge'
version false
columns {
id column:'cartridge_id', generator: 'assigned'
code_set_id column:'code_set_id'
runDate column:'run_date'
}
}
Actually, with those models, I get tables :
- code_set,
- cartridge,
- and table : code_set_cartridge (two fields : code_set_cartridges_id, cartridge_id)
I would like to not have code_set_cartridge table, but keep relationship :
code_set --> 1:n --> cartridge
In other words, how can I keep association between code_set and cartridge without intermediate table ? (using code_set_id as primary key in code_set and code_set_id as foreign key in cartridge).
Mapping with GORM can be done without intermediate table?
© Stack Overflow or respective owner