Does hibernate tool have the ability to connect to synonym tables in the database? I was asked about this by my the DBA this question.
Asked
Active
Viewed 4,985 times
3 Answers
6
yes, just enable the property 'hibernate.synonyms' in your persistence.xml
<properties>
<property name="hibernate.synonyms" value="true"/>
</properties>
And annotate your entity class with
@Entity
@Table(name = "<repalce with synonym name>")

Adrian Viesca
- 181
- 3
-
1Since the db is using synonyms is there something we can do to get the tables to be displayed in the configuration section of the hibernate tool? – zDroid Jun 25 '14 at 06:22
0
Found a solution, just avoid mentioning the schema in the cfg file.. my file ..
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@//localhost:60003/IHR1D</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property><property name="hibernate.default_catalog"/></session-factory>

zDroid
- 426
- 1
- 11
- 32
0
You can create a view from synonym table;
CREATE VIEW MY_VIEW AS ( SELECT * FROM MY_TABLE@SYNONYM)
Then you can create entity with that VIEW name:
@Entity
@Table(name = "MY_VIEW")

hurricane
- 6,521
- 2
- 34
- 44