views:

208

answers:

1

I'm developing a Java web application that uses Hibernate (annotations-based) for persisting entities to an Oracle 11g database. The DBA created synonyms for the tables and requested that I use these synonyms instead of the physical tables. (Eg: Table "Foo" has synonym "S_Foo")

If I have "hibernate.hbm2ddl.auto=validate" enabled, then the application fails on startup with "Missing Table: S_Foo". If I turn off the validation, then the app starts up fine and works properly. My guess is that Hibernate only checks against physical tables and not synonyms when validating that a table exists.

Is there any way to enable Hibernate schema validation with synonyms? Can I specify both a physical table and a synonym in the annotation? I prefer having that extra safety check that the table structure is correct when the application starts up.

A: 

I'm not to familiar with hibernate, but could you try views instead of synonyms. If you are just using these tables for views, it would work the same as a synonym. If you want to be able to do CRUD on the "table" though you'd need to build a bunch of instead-of triggers.

Matthew Watson