Not an answer. To experience the same behavior. Ask the author to find out if the following code matches the problem operator.
Types of objects and compound identifiers.
@Embeddable public class MyComposite implements Serializable { private static final long serialVersionUID = 5498013571598565048L; @Min(0) @Max(99999999) @Column(columnDefinition = "INT(8) NOT NULL", name = "id", nullable = false) private Integer id; @NotBlank @NotEmpty @Column(columnDefinition = "VARCHAR(8) NOT NULL", name = "code", length = 8, nullable = false) private String code;
Unit tests for classes
@Test public void createWithIdOutOfRangeTest(){ Exception exception = null; MyEntity input = new MyEntity(); MyEntity output = null; MyComposite id = new MyComposite(); // EITHER THIS id.setId(123456789); id.setCode("ABCDEFG"); // OR THIS id.setId(12345678); id.setCode(" "); input.setComposite(id); try { output = service.create(input); } catch (Exception e) { exception = e; } Assert.assertNotNull("No exception inserting invalid id !!", exception); Assert.assertTrue("There was some other exception !!", exception instanceof ConstraintViolationException); }
And as stated in the question, I get no exceptions that pass invalid values ββto the composite key fields ( Hibernate-core:5.0.12 , H2:1.4.196 ). The test does not work.
source share