For the life of me I cannot seem to get relationships to work on mapped tables with Grails. I have two domains I am trying to join, Resources and Cassettes. A Resource can have many Cassettes.
If i run the code below using scaffolding I get an error "Unknown column 'this_.cassette_id' in 'field list'". If i try to define the cassette_id in the mapping I get a fatal error upon compilation.
Can any wise Grails wizard set me on the correct path, I am new to this and have tried practically tried every method I can find to make this valid.
//resource definition
package edu.place.project
class Resource {
String title
String number
String type
Cassette cassette
static hasMany = [cassette : Cassette ]
static mappedBy = [cassette : "hvt"]
static mapping = {
table "Resources"
version false
columns {
id column : "resourceIdentifier2"
title column: "title"
number column: "extentNumber"
type column: "extentType"
}
}
static constraints = {
}
}
//Cassette definition
package edu.place.project
class Cassette {
String id
String type
String numCode
String hvt
static belongsTo = Resource
static mapping = {
table "ArchDescriptionInstances"
version false
columns {
id column : "barcode", type : String
type column : "userDefinedString2"
numCode column : "container1AlphaNumIndicator"
hvt column : "userDefinedString1"
}
}
static constraints = {
barcode(unique : true)
}
}