0

I have four domain classes having common properties, transID, createdDate wherein the transID is typed int and mapped as the Primary Key of the table. By rule of abstraction, we seperate the common properties/attributes to an abstract class then let the child class (which in my case the four domain classes I have) inherit them or extends it.

In my abstract class contains the two properties transID, createdDate but since the transID is set to be the Primary Key of the four child classes I have formatted this mapping inside the abstract class.

static mapping = {
  id generator: 'increment',
     name: 'transID',
     column: 'transID',
     type: int
}

I have no errors in running the project then, but when I check the tables on the dbconsole, I can't see the four tables with relation to the four domain class yet I only see the abstract class having the properties of the first child.

Is there a way to abstract the id of the mentioned domain classes or I have to mapped it to the child classes rather than having it in the abstract class.

Thanks.

David B
  • 3,269
  • 12
  • 48
  • 80

1 Answers1

1

By default GORM uses table per class hierarchy, so you will have just one table - if you want one table per subclass - you can configure so using GORM DSL - see Inheritance in gorm

But be careful before you use table per subclass excessively.

Sudhir N
  • 4,008
  • 1
  • 22
  • 32