apache / apache/grails-core

GORM doesn't respect table schema mapping on table-per-subclass inherited domain classes

Open
#14,644 7 comments 0 reactions 0 assignees View on GitHub
relates-to: gorm
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

**Grails 3.1.1, against an Oracle database**

When mapping a table-per-subclass strategy with a schema specified, the schema is picked up by the superclass, but not by the subclass. See below.

**class A**

```
mapping= {
table(schema: 'WOOT', name 'A')
tablePerHierarchy(false)
}
```

**class B extends A**

```
mapping= {
table(schema: 'WOOT', name: 'B')
}
```

**B.read(1)** results in:
`Hibernate: select ... from B this_ inner join WOOT.A this_1_`
Class B _does not_ have the schema prepended in the SQL statement.

Contributor guide

Open the contributing guide

Research direction

No repository file or test path is identified in the report. Start by reproducing the Grails 3.1.1 table-per-subclass mapping against Oracle, then trace the generated SQL for B.read(1); done means the subclass table is qualified with the WOOT schema like the superclass table.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.