Change default schema to oracle datastore

Is is possible to change the default schema to an oracle datastore in cuba platform?

Apparently the only way to achieve this is execute a sql sentence after connection.

ALTER SESSION SET CURRENT_SCHEMA=desired_schema_name

Please see:
jdbc - Default Schema in Oracle Connection URL - Stack Overflow

Since cuba studio uses the jdbc data store settings for the “generate model database” to work, it is using username as default schema name, but this is not always the needed one. There should be a way to set a different schema name

Hi,
Studio’s “Generate Model” feature doesn’t support generating model by tables from non-default schema. The “Generate database scripts” feature also doesn’t support it.

But the CUBA runtime can work fine with such tables.

I would suggest the following:

  • backup and restore table definitions from your desired_schema_name to some other Oracle server where they will appear in the default schema.
  • run Generate Model from that schema
  • manually change all definitions of entities, use @Table(name = "...", schema="desired_schema_name")
  • switch back data store settings to the original connection.

After that entities from non-default schema should be read and written by the CUBA successfully.

Hi @AlexBudarov, thank you for your response.

I’m not able to backup and restore, since I have read only access. But I will give it a try to manually setting schema as you advised.

Is the “generate model” a proprietary source or is it published on github? Or may be cuba-cli?

You don’t need write access.
I guess that read only access to the schema is enough to make backup of tables schema.

Then you can restore this schema on any other Oracle server, e.g. installed locally, and import tables from there.

CUBA Studio is a closed-source product.

The cuba-cli tool doesn’t have Generate Model feature.