SpaceCowboy
Aug 4th, 2010, 04:17 AM
Hello,
I have an issue and wondered whether this was a grails 1.3.3. bug or me not understanding grails ?
To summarize: Mappings defined in abstract class do not get reflected in child domain class table
The test case:
I have a basic domain class that extends an abstract class and some mappings in both.
public abstract class AbstractAirline {
static mapping = {
id column: 'airline_id'
name column:'airline_name'
description column: 'airline_details'
}
String name
String description
}
class Airline extends AbstractAirline{
static mapping = {
table 'airline'
frequentFlyer column: 'frequent_flyer'
iata column: 'iata_number'
}
String frequentFlyer
String iata
}
The result:
However when GORM generates the tables it does not honour the mappings from the abstract class, so you end up with the default names and id:
PUBLIC.AIRLINE
ID
VERSION
DESCRIPTION
FREQUENT_FLYTER
IATA_NUMBER
NAME
The expected result:
PUBLIC.AIRLINE
AIRLINE_ID
VERSION
AIRLINE_DETAILS
FREQUENT_FLYTER
IATA_NUMBER
AIRLINE_NAME
Any help would be appreciated,
Thanks
I have an issue and wondered whether this was a grails 1.3.3. bug or me not understanding grails ?
To summarize: Mappings defined in abstract class do not get reflected in child domain class table
The test case:
I have a basic domain class that extends an abstract class and some mappings in both.
public abstract class AbstractAirline {
static mapping = {
id column: 'airline_id'
name column:'airline_name'
description column: 'airline_details'
}
String name
String description
}
class Airline extends AbstractAirline{
static mapping = {
table 'airline'
frequentFlyer column: 'frequent_flyer'
iata column: 'iata_number'
}
String frequentFlyer
String iata
}
The result:
However when GORM generates the tables it does not honour the mappings from the abstract class, so you end up with the default names and id:
PUBLIC.AIRLINE
ID
VERSION
DESCRIPTION
FREQUENT_FLYTER
IATA_NUMBER
NAME
The expected result:
PUBLIC.AIRLINE
AIRLINE_ID
VERSION
AIRLINE_DETAILS
FREQUENT_FLYTER
IATA_NUMBER
AIRLINE_NAME
Any help would be appreciated,
Thanks