Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.0.2
-
Fix Version/s: 1.1-beta3
-
Component/s: Persistence
-
Labels:None
Description
If I have the following two classes:
class Employee {
static hasMany = [projects: Project]
static mapping =
}
class Project {
static belongsTo = Employee
}
I expect three tables (EMPLOYEE, PROJECT, EMP_PROJ), but instead of EMP_PROJ I get EMPLOYEE_PROJECT. It ignores the joinTable:name parameter (but not the column or key parameters). The reason is the belongsTo clause in Project. If I remove the belongsTo then I get EMP_PROJ as I wanted, but now Employee.delete() doesn't cascade to the related Projects. The workaround is to explicitly define the cascade behavior using something like:
projects joinTable: [name: 'EMP_PROJ', column: 'PROJECT_ID', key: 'EMPLOYEE_ID'], cascade: 'all,delete-orphan'
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
If you use cascade as a workaround for belongsTo, the validation does not cascade.