Wrong Sequence location in Database!

Hello! Here is the issue…

I have two Data Stores - Main (with Cuba internal structures) and Business (with legacy data of our Domain). Both stores - are schemas in Oracle database.

I successfully created the entity class mapped on some legacy table, place this class in Business-persistent.xml. All works fine.

But then I decided to add @IdSequence annotation to my class, because there is the sequence used for generating new ids for long ago. And after the addition of @IdSequence(name=“MY_EXISTING_SEQUENCE”) Cuba generate new sequence in Main Store (instead of using the one with same name in Business store…).

As I said I use Oracle schemas for both stores, hence there can be walkaround - to create synonyms for all sequences from Business schema in Main schema… But it seems really cumbersome. Would you please consider adding some params to @IdSequence annotation to configure Sequence placement.

Suggested workaround with synonym is not working :frowning: At least in Oracle. There is the error ORA-00955: name is already being used by existing object.

Hi,
You did not told us your Cuba version.
For v 7.0 you can use an application property
cuba.useEntityDataStoreForIdSequence
(For more details see in the docu)

BR
Steven

BTW - please use the search - you will find similar issues.

2 Likes

The version in 7.1
Thank you very much!
I’ll search more accurately in future, sorry!

Steven,
would you please consider the following suggestion…

We have legacy Oracle database with 3 schemas - SCHEMA0, SCHEMA1, SCHEMA2. Schema0 is something like “dictionary” and schemas 1 and 2 are “business”. Schema0 contains shared sequences for entities in schemas 1 and 2. For example: both schema 1 and 2 have PEOPLE table, and schema 0 has PEOPLE_SEQ sequence. Schemas 1 and 2 have synonyms to this sequence. Such legacy structure is invisible for current business applications (NHibernate/C#) (synonym for sequence equals to sequence).

But in Cuba’s class OracleSequenceSupport there is sequence existing check:
modules/core/src/com/haulmont/cuba/core/sys/persistence/OracleSequenceSupport.java
@Override public String sequenceExistsSql(String sequenceName) { return "select SEQUENCE_NAME from USER_SEQUENCES where SEQUENCE_NAME = '" + sequenceName.toUpperCase() + "'"; }

This logic does not consider existence of synonyms (from USER_SYNONYMS table). Or maybe better: select * from user_objects where OBJECT_TYPE in ('SYNONYM', 'SEQUENCE');

Maybe it will be useful to add config parameter to extend such check.

P.S. In docu I found that it is possible to redefine such behaviour on application level: DBMS Version - CUBA Platform. Developer’s Manual

Hi Baraserg,

I saw the same problem by another user in a previous topic.

I’m not sure if the suggested solution is still valid - I would kindly point to the Cuba support team to give a answer what is best in V 7.1.

I know this is not a ready to use solution for you, but I hope it helps you with the next steps…

BR
Steven

1 Like