1:N Association Constraint Name collision

hi,

when creating two different entities, that have both an 1:N association to another entity and the name of both entities starts with the same first letter, the sql files that get created, has a problem because of a naming collision.

Here is an example:

Entities:

  • Order
  • Options
  • File Descriptor

Associations:

  • Order M:N File Descriptor
  • Options M:N File Descriptor

which just means, that you can attach many files to orders and to options.

In this scenario the file “20.create-db.sql” will contain the following two entries (where RYS is the project prefix):

alter table RYS_ORDERS_FILE_DESCRIPTOR_LINK add constraint FK_ROFDL_FILE_DESCRIPTOR foreign key (FILE_DESCRIPTOR_ID) references SYS_FILE (ID)^
alter table RYS_OPTIONS_FILE_DESCRIPTOR_LINK add constraint FK_ROFDL_FILE_DESCRIPTOR foreign key (FILE_DESCRIPTOR_ID) references SYS_FILE (ID)^

When creating the db the following erros occur:

Executing SQL script: /home/user/dev/cuba/rys/modules/core/build/db/50-rys/init/hsql/20.create-db.sql
Failed to execute: alter table RYS_OPTIONS_FILE_DESCRIPTOR_LINK add constraint FK_ROFDL_FILE_DESCRIPTOR foreign key (FILE_DESCRIPTOR_ID) references SYS_FILE (ID) because: object name already exists: FK_ROFDL_FILE_DESCRIPTOR in statement [alter table RYS_OPTIONS_FILE_DESCRIPTOR_LINK add constraint FK_ROFDL_FILE_DESCRIPTOR foreign key (FILE_DESCRIPTOR_ID) references SYS_FILE (ID)]

I get across this by updating the 20.create-db.sql file manually. The problem is, that sometimes the file seems to get overriden (i’m not 100% sure when this happens).

Can anybody confirm this behavior?

Thx,
Mario

Hi Mario,

Thank you for pointing out the problem.

We abbreviate long DB names due to Oracle 30-characters restriction, and it really can cause problems, as in your case. We’ll think about it and maybe make abbreviations more smart.

As for when Studio overrides manual changes - it should do this only when you modify the owning table. For example, if you add an attribute to the entity, the whole text between comments “–begin TABLE” and “-- end TABLE” will be overridden.