'IllegalStateException: Generated ID is null' when saving entity with id annoteted by @JmixGeneratedValue

  1. create jmix 1.0.0 project (jdk 11.0.8)
  2. add new JPA Entity with Id type UUID (annotated @JmixGeneratedValue by default)
  3. Add mandatory String attribute
@Table(name = "TEST")
public class Test {
    @Column(name = "ID", nullable = false)
    private UUID id;

    @Column(name = "NAME", nullable = false)
    private String name;
  1. Create Master-detail screen
  2. Start application and create entity - all works
  3. Generate onAfterInit event handler
    public void onAfterInit(AfterInitEvent event) {
        Test test = new Test();
        test.setName("test name");
  1. Open Master-detail screen: IllegalStateException: Generated ID is null in com.company.test3.entity.Test-null [new]

Caution of @JmixGeneratedValue documentation says: Note that the @JmixGeneratedValue annotation doesn’t take any effect if you create an entity instance using the new operator. See instantiating entities for proper methods of creating new instances.

1 Like