apache / apache/grails-core

Unable to map composite-id based entities from request body

Open
#14,823 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Expected Behavior

I have 2 entities both have composite id without composite key.

`class User{
Integer id
Integer tenantId
Address address
static mapping {
id composite:['tenantId', 'id']
}
}`

`class Address{
Integer id
Integer tenantId
String city
static mapping {
id composite:['tenantId', 'id']
}
}`

`User save(User user){
println(user.address) //prints null, exprected address object like it works in with non-composite keys
}`

Request form:
`address=1`

tenantId will be resolved from Multi-Tenancy feature.

### Actual Behaviour

_No response_

### Steps To Reproduce

_No response_

### Environment Information

_No response_

### Example Application

_No response_

### Version

6.2.3

Contributor guide

Open the contributing guide

Research direction

Start at the User.save(User user) entry point and request-form binding for address=1, using the two composite-id entities and the tenantId supplied by multi-tenancy. Reproduce the null User.address result and trace the binding and entity lookup; done when the Address object is populated as it is for non-composite keys.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.