Question

I am using MyBatis 3 to create a request (seen below) however, I am getting: ORA-00942: table or view does not exist where SYNONYM_A is a public Synonym for a table in another database...

I know the example doesn't really help, but the real question is, "Is there a special syntax for synonyms in Batis?" Has anyone done this, or failed, and can tell me, so I don't spend a great deal of effort, if it is not valid in Batis?

@Select("select * from SYNONYM_A where some_det_key in (SELECT DATA_KEY FROM SOME_PARENT_TABLE WHERE PARENT_KEY = 1234 AND (ATTACH_PARENT_FLG = 1 or ATTACH_PARENT_FLG is null) AND DATA_SRC = 'LV_SOME_DET') ORDER BY pair

Was it helpful?

Solution 3

The answer is....

I was connected to the wrong database instance!! I had built extended AbstractRoutingDataSource, and was pulling the server name for the datasource from a primary database. I discovered that another individual had populated this table incorrectly, and pointed me to a database where the synonym did not exist.

Thank you for your responses, and your time.

OTHER TIPS

Provide the select grant FROM the PARENT schema to the current schema once again for the table of which SYNONYM_A is a synonym of.

And is SYNONYM_A a synonym for a Table or a synonym of another SYNONYM in the PARENT schema? In case it is, u need to provide grant from the ultimate base schema where the actual table is located once again 'WITH GRANT OPTION'

A public synonym does not mean that grants are not required from the schema in which the parent table lies(if the synonym and the table lies in two different schemas, that is). You need to clarify your concept of public synonyms :) .

But thats not the point here. just do:

SELECT * SOME_TABLE"@"CONNECTION_TO_ANOTHER_DATABASE;

If this gives you ORA-XXXX: Table or view doesnot exist, then this is the cause.

There are two possibilities:

1.CONNECTION_TO_ANOTHER_DATABASE has got corrupted/doesnot exist. You can check this by doing queries like :

Select sysdate from duals@CONNECTION_TO_ANOTHER_DATABASE;
Select * from user_objects@CONNECTION_TO_ANOTHER_DATABASE;

If this too gives you the same error then that's it, your CONNECTION_TO_ANOTHER_DATABASE is gone.

If this does not give any error and gives some valid o/p then:

2.Probably the "SOME_TABLE" at the remote database does not exist!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top