Uploaded image for project: 'Hibernate ORM'
  1. HHH-12536

ORM does not interpret Hibernate Validator constraints as DDL statements for @Embeddable attributes


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Rejected
    • Affects versions: 5.2.16
    • Fix versions: None
    • Components: hibernate-core
    • Environment:
      I am using Spring Boot 2.0.1.RELEASE which pulls in Hibernate 5.2.16.Final with Hibernate Validator 6.0.9.Final
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
    • Sprint:



      I am using Spring Boot 2 (2.0.1.RELEASE) with the default Hibernate version with H2 db and I have a problem with the field sizes in the table that is generated when using @Embeddable.

      Here is my code:

      public class Publisher

      { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @NotBlank @Size(min=2, max=150) private String name; @NotNull private Address address; ... }

      public class Address

      { @NotBlank @Size(min=3, max=100) private String street; @NotBlank @Size(min=2, max=100) private String city; @NotBlank @Size(min=2, max=100) private String county; @NotBlank @Size(min=7, max=8) private String postcode; ... }

      When Spring Boot fires up it creates the tables in H2. The column size in the 'name' attribute in Publisher is correctly set up to 150 using the max value from the @Size annotation.

      The max values in the @Size annotations for the embedded Address entity is ignored and set to 255 chars max for all 4 fields.

      Is this the expected behaviour or should the db columns from the embedded fields be set to the max value from the @Size annotations in the Address entity?

      I know I can set this using the length value of the @Column annotation but I was hoping to get this working without the extra @Column annotation.

      I originally raised this question on StackOverflow and was asked to submit this here:


      I haven't used Jira for a very long time so I apologise in advance if I make any mistakes in raising this issue.

      Thank you




            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: