Generated index name too long

Hi Team,

When compositing two entities, CUBA will create index on foreign key automatically. However, if I have 2 entities with long names, the generated index name will exceed 64 char limit.

For example, I have 2 entities: TestLongEntityNameGeneratedIndex and TestLongEntityNameGeneratedIndexTwo, if I create one-on-one mapping, it will generated:

create index IDX_CUBATEST_TEST_LONG_ENTITY_NAME_GENERATED_INDEX_TWO_ON_RELATED_LONG_NAME_ENTITY on CUBATEST_TEST_LONG_ENTITY_NAME_GENERATED_INDEX_TWO (RELATED_LONG_NAME_ENTITY_ID);

The index name is too long. Can we apply the “shorten” method to index name like we did in Jmix to shorten project id?

Thanks!

Hi,
Which Studio version do you use?
What is database type is in the datastore where you create those entities?
Can you show entities source code?

I tried to reproduce the problem, and Studio shortened index name for me:

@Table(name = "PLAYGROUND_TEST_LONG_ENTITY_NAME_GENERATED_INDEX")
@Entity(name = "playground_TestLongEntityNameGeneratedIndex")
public class TestLongEntityNameGeneratedIndex extends StandardEntity {
    private static final long serialVersionUID = -4595947020788563349L;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "RELATED_LONG_NAME_ENTITY_ID")
    private TestLongEntityNameGeneratedIndexTwo relatedLongNameEntity;
// ...

Led to:

create index IDX_PLAYGROUND_TESTLONGENTINAMEGENEINDE_ON_RELALONGNAMEENTI on PLAYGROUND_TEST_LONG_ENTITY_NAME_GENERATED_INDEX (RELATED_LONG_NAME_ENTITY_ID);

(59 characters)

Hi Alex,

I’m using:
CUBA Platform version: 7.2.11
CUBA Studio plugin version: 15.2-202
IntelliJ version: IntelliJ IDEA 2020.3.2 (Ultimate Edition)

Database is HSQLDB.

Attached the test project.
cubatest.zip (97.7 KB)

You can check the file db/update/hsql/21/02/210222-2-createTestLongEntityNameGeneratedIndexTwo.sql

Hi!
Thank you for reporting the problem. We have created a YouTrack issue.

Regards,
Elena

1 Like