apache / apache/grails-core

Identity enumType for Set of enums

Open
#14,571 0 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

### Task List

- [ ] Steps to reproduce provided
- [ ] Stacktrace (if present) provided
- [ ] Example that reproduces the problem uploaded to Github
- [ ] Full description of the issue provided (see below)

### Steps to Reproduce

In grails 3.3 currently impossible to define enumType for a collection of enums. It works only for a separate field:
https://docs.grails.org/latest/ref/Database%20Mapping/column.html

@jameskleeh wrote: **I don't think this is possible currently**
https://stackoverflow.com/questions/50210992/grails-3-enumtype-for-set-of-enums?noredirect=1#comment87450991_50210992

With grails 3.2 following code works well, but with grails 3.3 it use enum names during saving to DB

```
class Test {
Set enums
static mapping {
enums enumType: 'identity' // not works
}
}

enum TestEnum {
final int id
TestEnum(int value){
...
}
}

```

- **Operating System**: TODO
- **GORM Version:** 6.1.9
- **Grails Version (if using Grails):** 3.3.5
- **JDK Version:** TODO

### Example Application

- TODO: link to github repository with example that reproduces the issue

Contributor guide

Open the contributing guide

Research direction

Start by comparing Grails 3.3/GORM 6.1.9 collection enum mapping with the reported Grails 3.2 behavior and the column mapping documentation linked in the issue. Confirm the behavior with the shown Test and TestEnum mapping; done means a Set of enums persists and reloads using each enum's identity value rather than its name.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.