Customize sequence cache size for specific entities

Dear all,
My project is currently in its final stage of development. For certain entities, the table sequences are modified by stored procedures at the database level. Because of this, I would like to configure the sequence cache size for those entities to 1 in order to ensure correct behavior.

I am aware of the jmix.data.number-id-cache-size configuration, which allows adjusting the cache size. However, this setting applies globally to all entities. If I change this configuration, I would need to update all sequences in the system, which is risky at this stage of the project.

Could you please advise me on the recommended way to achieve this customization for specific entities only?

Thank you for your support.

Hi @krivopustov ,
Could you please suggest a solution for this issue? I would really appreciate your help.

Thank you.

Hi @lewiyil914

The sequence cache will not be used for an entity if you just specify the sequence name explicitly in the @JmixGeneratedValue annotation, for example:

@JmixEntity
@Table(name = "FOO")
@Entity
public class Foo {
    @JmixGeneratedValue(sequenceName = "MY_FOO_ID_SEQUENCE")
    @Column(name = "ID", nullable = false)
    @Id
    private Long id;

This sequence will be created automatically if it doesn’t exist.

The cache is used by default only for when @JmixGeneratedValue doesn’t specify the sequence name. Otherwise it requires also sequenceCache = true attribute of the annotation.

Regards,
Konstantin

1 Like

I have tested it, and the result is exactly as expected.
Thank you very much!!!