grails-data-mapping
grails-data-mapping copied to clipboard
Identity length is not working with MappingBuilder.orm
Task List
- [x] Steps to reproduce provided
- [ ] ~Stacktrace (if present) provided~
- [ ] ~Example that reproduces the problem uploaded to Github~
- [x] Full description of the issue provided (see below)
Steps to Reproduce
- Create a simple domain class.
- Add the following mapping block-
import grails.gorm.hibernate.mapping.MappingBuilder
class User {
String id
static mapping = MappingBuilder.orm {
id generator: "assigned", length: 20
// Tried below as well
// id generator: "assigned", maxLength: 20
// id generator: "assigned", params: [length: 20]
}
}
- Run the app and check the table
desc user
in MySQL.
Expected Behaviour
The id
column should be created as VARCHAR(20)
.
Actual Behaviour
The id
column is being created as VARCHAR(255)
.
Environment Information
- Operating System: macOS Catalina 10.15.7
- GORM Version: 7.0.6
- Grails Version (if using Grails): 4.0.4
- JDK Version: Oracle JDK 1.8.0_91
Description
To use types and @GrailsCompileStatic
annotation, I'm using MappingBuilder.orm
in the mapping
block.
https://stackoverflow.com/a/60118491/2405040
Any update here?
Did you try maxSize
?
Ref: http://gorm.grails.org/latest/hibernate/manual/index.html#_constraints_and_database_mapping