I've recently added synonyms to our DB. These synonyms hold the entire entity information, hence have their own mapping file. Connecting to the synonyms is not an issue. The issue is when using the hbm2ddl tool.
If I include the synonym mapping files, the hbm2ddl tool creates the synonym table as a normal table, it should be ignored. I'm not sure how to flag the entity mapping as a synonym (or if possible) and restrain hibernate from creating a new table for this synonym.
If I exclude the mapping files, then the tool does not pass validation since other files refer to the synonym entities. Example:
<many-to-one name="creator" class="com.entities.MySynonymEntity" cascade="refresh" foreign-key="MY_SYNM_FKC" not-null="false" lazy="proxy" fetch="select">
<column name="MY_SYNM_FK" not-null="false" sql-type="NUMBER(19)" />
</many-to-one>
Here the mapping file belong to an entity which lives in the true database but refers to an entity whose data is populated from a synonym.
What would be the correct way to setup your mapping files for the hbm2ddl tool when synonyms of involved?
Thanks much, JP