Changing entity name convention from $ to _

Hi
While I am migrating my project created in CUBA platform to JMIX, I want to replace the $ sign by _ as “_” is used by default in JMIX.

from

@JmixEntity
@Table(name = "ERP_ACCOUNTS_BALANCE")
@Entity(name = "erp$AccountsBalance")
public class AccountsBalance extends StandardTenantEntity {

to

@JmixEntity
@Table(name = "ERP_ACCOUNTS_BALANCE")
@Entity(name = "erp_AccountsBalance")
public class AccountsBalance extends StandardTenantEntity {

Can I just replace it in the Entities and codes or there is more to be taken care off? Is there any impact to the application database for this change?

Entity name has no any impact to the application database. Just change names in @Entity annotations and everywhere in java code and screen xml descriptors. Dont forget about runtime resource roles and row-level roles.

1 Like

I am thinking of refactoring the name so that it updates everywhere at the code level.

Yes, IntelliJ refactoring will work fine, I made a test on a copy of one small project.
I guess also text editors with "replace in files " function would do the same.

1 Like

Just as a side note:

Some addons (and I think also some platform functionality) have those names stored in the database. So probably it is a good idea to go through the tables and do a sanity check if there is something. Might be on the filter definitions or the audit logging. For sure the entity soft reference addon (and thus also attachable, taggable, etc.).

Cheers
Mario

You’re right Mario. Another example would be the reports, especially when JPQL query is used.

I see it’s going to be a painful journel to manage those things but no way! since I want to move my application to FLOW where $ mark in Entity name doesn’t work in JQPL designer.

Look at report_report database table and use sql query like

update report_report set xml = replace(xml, 'erp$', 'erp_') where xml like '%erp$%'
1 Like

Alternatively I have a gut feeling that it is possible to replace underscore with dollar as part of the JPA layer.

This way you could avoid messy DB migrations, but in source switch to the new version. Or at least do a lazy migration.

You can take a look at the jmix/JpqlQueryStringProcessor.java at master · jmix-framework/jmix · GitHub and try to override its methods to perform a replacement within there.

Not sure which one is the best injection point but Jmix has a couple (and eclipselink as well).

Jmix itself uses a couple of extension points to rewrite the JPQL query like the macros “@between”. In the end this replacement would be a very similar but simpler macro.

Perhaps you find something there.

Cheers
Mario