This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have a couple of oracle databases that I need to deal with. I'm using the sequence identity method. I'm wondering what is the best manner in dealing with this situation. On database1, I need to access tables in two different schemas. Since the lightspeed sequence was created in one schema, should I: 1. Create a synonym to the sequence so the other schema can select from it? And provide select grants if needed? 2. Create two separate sequences? On database2, I need to access a table in one schema. Should I: 1. Set up two separate LightSpeedContext<CMDBUnitOfWork> for each separate connection? 2. What about the sequence in this situation? Should I crate another synonym using a dblink? 3. Two different models?
Thanks!
|
|
|
Setting up sequences when tables are across two schemas LightSpeed will, by default, try to select from the sequence in the LightSpeedContext.Schema (if this isn't specified, then Oracle will use the default schema i.e. the login user). So if you have only one LightSpeedContext you need only one sequence, even if some of the tables are in schemas other than the LightSpeedContext.Schema. You should not need to create a second sequence or a synonym. Accessing tables from multiple databases Yes, you will need to set up two LightSpeedContexts, because you need two different connection strings. Each LightSpeedContext will attempt to find the sequence from its own LightSpeedContext.Schema, using its own LightSpeedContext.ConnectionString. If you want the two databases to share the same sequence then you will need to create a synonym/link at the database end of things, because the two LightSpeedContexts will be connecting to different places. If you do not care about sharing the same sequence, then just create independent sequences in the two databases. It is not strictly necessary to create two different models if you are careful. Obviously, if you use Connection String #2 to try to load from a table that only exists in Database #1, this will cause an error; worse, if a compatible table does exist in Database #2, then you will end up loading from this table, just as if you had issued a SELECT statement to the wrong database. Note that associations must NOT span databases, because everything in an association graph gets saved through the same unit of work, i.e. the same connection. Also, if you are using the designer, using a single model for two databases will prevent you from using database synchronisation or migrations (because the designer syncs to a single database). My inclination would be to use different models but it does depend on your scenario and the relationship between the things in Database #1 and the things in Database #2. |
|
|
Ok great. Looks like I was doing all the right things. It does seem to work with a single sequence and no synonym. Thanks for the help. |
|