Search code examples
javaoracle-databasespringdbunit

Is there a difference between running DBUnit as a USER or OWNER of a schema


Currently I'm using DBUnit for testing my webservices.

When I specify the db user credentials with the OWNER of the schema everything works just fine.

If I change the db credentials to login as a USER I get:

> [Main Thread] ERROR org.dbunit.database.DatabaseDataSet - Table   
> 'ens_mrm_configuration' not found in   
> tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[],   
> _tableMap={}, _caseSensitiveTableNames=false]

I'm aware the the OWNER should first grant SELECT, UPDATE and INSERT for all tables I want to access (so I did just that) I also created SYNONYMS to refer to the actual tables. In the end both scenario's work, but the first test fails with this ERROR If I run the tests as a USER.

So is there a difference how DBUnit handles this? Im currently working with dbunit 2.4.8 and SpringJUnit.

UPDATE So I found out that I made a mistake my bad. The tests actually don't work at all when I test with the USER credentials.


Solution

  • Exactly how are you creating the synonyms?

    In Oracle, a synonym can be either public (in which case it is visible to all users) or private (in which case it is visible only to the owner of the synonym). Are you creating public synonyms? Or are you creating private synonyms?

    Public synonyms are created using the PUBLIC keyword

    CREATE PUBLIC SYNONYM ens_mrm_configuration
       FOR schema_owner.ens_mrm_configuration
    

    while private synonyms are not

    CREATE SYNONYM ens_mrm_configuration
       FOR schema_owner.ens_mrm_configuration
    

    If you are creating private synonyms, the synonyms need to be created in the USER schema.

    If you log in as USER, can you run this query and post the results

    SELECT owner, object_name, object_type
      FROM all_objects
     WHERE object_name = 'ENS_MRM_CONFIGURATION';