Grails

tablePerHierarchy false & custom table name forces table name directive in subclasses

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.0.2
  • Component/s: Persistence
  • Labels:
    None
  • Environment:
    Windows 2000, Java 5, Oracle 10 / Vista, Java 6, HSQLDB

Description

When using 'tablePerHierarchy false' and a custom table name for a domain class and not specifying custom table names for subclasses of that class,
Grails fails to generate a correct database schema for these classes. Depending on the platform Grails fails to start or crashes when trying to save an instance of a subclass.
Specifying custom table names for the subclasses or deleting the 'table xyz' directive from the base class removes the problem.

Example classes to reproduce behaviour:

class Base {

String bogus

static mapping = { tablePerHierarchy false table "base_table" }

}

class Derived extends Base { String extra }

Issue Links

Activity

Hide
Martyn Hiemstra added a comment -

I got this error but it was because my parent object wasn't abstract. Try making the parent object abstract and add tablePerHierarchy false to the parent objects mapping and then it should work.

This has been tested in version 1.2.0

Show
Martyn Hiemstra added a comment - I got this error but it was because my parent object wasn't abstract. Try making the parent object abstract and add tablePerHierarchy false to the parent objects mapping and then it should work. This has been tested in version 1.2.0

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: