Thursday, April 9, 2009

Hibernate schema definition and Oracle public synonym

Make sure that you don't specify schema in Hibernate mappings if you have public synonym defined for tables in Oracle.

Here is the setup. I had a table MY_TABLE mapped in MyTable.hbm.xml. In the database, a public synonym "MyTable" is created for MY_TABLE. I also had two schema definitions in Hiberante. One is the default schema in Spring config.



The second is in MyTable.hbm.xml


At runtime, Hibernate has problem resolving and working on the right table. It worked after schema definitions were removed from both places and left the resolution to Oracle.

1 comment:

  1. wonderful piece of information, I had come to know about your blog from my friend Nandu , Hyderabad, I have read at least 7 posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that I had been looking for, I'm already your RSS reader now and I would regularly watch out for the new posts, once again hats off to you! Thanks a ton once again, Regards, Synonyms In Oracle

    ReplyDelete