Grails

Problem with Subclass Mapping and Inhritance

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Duplicate
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.0.2
  • Component/s: Persistence
  • Labels:
    None
  • Environment:
    Grails 1.0.1. Groovy. Windows XP Professional

Description

Hello Guys,

I need any help with Inheritance and mapping subclasses! See that I`m using tablePerSubclass!

My data base is postgres!

In my case I have the following classes:

This is the parent-class:

class Duty {

String description
Date begin
Date end
Date include
City city
Region region
Contry country

static mapping = { tablePerHierarchy(false) table('tbduty') version(false) id(generator:'increment',column:'idduty') description(column:'dsduty') begin(column:'dhdutybegin') end(column:'dhduryend') include(column:'dhinclude') city(column:'idcity') region(column:'idregion') country(column:'idcountry') }

String toString() {"${this.description}"}

}

And this is child-class:

class DutyEvent extends Duty {

boolean newsletter
String localEvent
String coment

static constraints = { localEvent(maxSize:80, blank:false) coment(maxSize:500, blank:true) }

static mapping = { table('tbdutyevent') version(false) id(generator:'increment', column:'idduty') newsletter(column:'innewsletter') localEvent(column:'nmlocal') coment(column:'txcoment') }
}

My problem is when try to access dutyevent controller in list action I have this error message:
Caused by: org.postgresql.util.PSQLException: ERROR: column this_.id does not exist

It seems like my id from sub-class(DutyEvent) is not mapped! Someguys, in another forum told me that I have to map all the content in child class.
Another one, instead, told me that this is a bug from grails 1.0.1.

This looks weird!

Could anyone help with this?!

And bellow, it`s my data base script of tables:

(child-class)
CREATE TABLE tbdutyevent
idduty integer NOT NULL,
nmlocal character varying(80),
txcoment text,
innewsletter character(1),
CONSTRAINT pk_tbdutyevent PRIMARY KEY (idduty)
)

(Parent-class)
CREATE TABLE tbduty
(
idduty integer NOT NULL,
dsduty character varying(500),
dhdutybegin date,
dhdutyend date,
dhinclude date,
idcity integer,
idregion integer,
idcountry integer,
CONSTRAINT pk_tbduty PRIMARY KEY (idduty)
)

Thanks for all folks!
Sergio Teixeira.

Activity

Hide
Graeme Rocher added a comment -

already fixed

Show
Graeme Rocher added a comment - already fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: