grails-data-mapping icon indicating copy to clipboard operation
grails-data-mapping copied to clipboard

Identity length is not working with MappingBuilder.orm

Open sagrawal31 opened this issue 3 years ago • 2 comments

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

  1. Create a simple domain class.
  2. 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]
    }
}
  1. 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

sagrawal31 avatar Oct 15 '20 12:10 sagrawal31

Any update here?

sagrawal31 avatar Nov 27 '20 06:11 sagrawal31

Did you try maxSize?

Ref: http://gorm.grails.org/latest/hibernate/manual/index.html#_constraints_and_database_mapping

puneetbehl avatar Nov 27 '20 22:11 puneetbehl