12

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.

Rob
  • 121
  • 1
  • 3
  • Can you post the full stack trace and also mention the versions of Hibernate, jdbc driver and the dialect. – Pascal Thivent Jun 11 '10 at 16:40
  • Were the synonyms created as PUBLIC synonyms, or synonyms owned by the user that Hibernate logs in as? This might affect the outcome. (or it might not) – Jeffrey Kemp Jun 12 '12 at 05:25

2 Answers2

-2

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
  • 14,083
  • 9
  • 62
  • 82
-2

Change hibernate.hbm2ddl.auto=validate to hibernate.hbm2ddl.auto value = "" then it won't fail.

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
Pedro
  • 13
  • 2