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.
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.
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.