IllegalArgumentException: entityId is null

I have this case: in entity I set a sequence with @GeneratedValue and @SequenceGenerator.
I use a Db where it is set for each ID(primary key) to have auto increment with special sequense. This is the reason to use this annotation to connect corrently the sequense.

When I try to insert a new record, the jmix displays this error (entityId is null) but the data is inserted in db.

I try to fix it with your @JmixGeneratedValue(sequenceName = “sequence_name”),
but it genarates a new Id always when I open the screen for inserting, no matter if I save the data in db or not.

I want to generate a new ID only when i have a record in db.

thank you an advance :slight_smile:
I have this case: in entity I set a sequence with @GeneratedValue and @SequenceGenerator.
I use a Db where it is set for each ID(primary key) to have auto increment with special sequense. This is the reason to use this annotation to connect corrently the sequense.

When I try to insert a new record, the jmix displays this error (entityId is null) but the data is inserted in db.

I try to fix it with your @JmixGeneratedValue(sequenceName = “sequence_name”),
but it genarates a new Id always when I open the screen for inserting, no matter if I save the data in db or not.

I want to generate a new ID only when i have a record in db.

thank you an advance :smile:

Hello,
Thank you for highlighting the issue.

Unfortunately, we cannot reproduce the problem. We will be able to help you if you send us a small sample project along with step by step scenario of actions taken prior to getting an error.
Also,in case you will encounter any other problems in the future - it would help us a lot if you could share with us the following data:

  • your environment specifications (OS/IDEA versions and any additional libraries used)
  • jmix / jmix.plugin versions

Hi @georgi.minchev
Use the following parameters when creating entity (with or without “Has UUID” trait):

image

You will get entity code like this, and it should work:

@JmixEntity
@Table(name = "FOO")
@Entity
public class Foo {
    @Column(name = "ID", nullable = false)
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "foo_seq")
    @SequenceGenerator(name = "foo_seq", sequenceName = "foo_seq", allocationSize = 1)
    private Long id;

// ...

Hi,

Here is my test project https://github.com/gminchev1982/documents-jmix/tree/master

  1. in Document Entity i set the sequence with
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = “DOCUMENTS_ID_SEQ”)
    @SequenceGenerator(name = “DOCUMENTS_ID_SEQ”, sequenceName = “DOCUMENTS_ID_SEQ”, allocationSize = 1)

When I save a new record I received: EntityId is null

  1. In CorrespondenceType Entity : I set the sequence with @JmixGeneratedValue(sequenceName = “CORRESPONDENCE_TYPE_ID_SEQ”)

Always when I open the screen for inserting, the Id field has a new value(+1) no matter if I save the data in db or not.

I want to generate a new ID only when i have a record in db.

Hi Georgi,
Thanks for the project.

Remove all Lombok annotations from the Document entity, and it will work as expected.

Lombok enhancements prevent from correct generation of ID required for displaying entities in UI.

Regards,
Konstantin