Joined: Thu Oct 20, 2011 11:43 am Posts: 1
|
I am new to Hibernate and am using 3.6.6 to interact with an Oracle 11g database instance. The application that I am working on requires the identification of DBMS specific keywords. I attempted to use the Dialect.getKeyWords() method against an Oracle 11g instance via the Oracle10gDialect. However, the method returns an empty set of Strings. The snippets below are the hibernate.cfg.xml and source code stub respectively. Is there a method call or config entry that I've omitted? What am I missing?
hibernate.cfg.xml
<hibernate-configuration> <session-factory name="importDefPOC_session"> <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <property name="hibernate.connection.password">xxx</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@server:port:sid</property> <property name="hibernate.connection.username">userID</property> <property name="hibernate.default_schema">SchameName</property> <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.connection.pool_size">1</property> <property name="hibernate.current_session_context_class">thread</property> <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <property name="hibernate.session_factory_name">importDefPOC_session</property> <property name="hibernate.jdbc.batch_size">50</property> <mapping resource="Some mapping 1..."/> <mapping resource="Some mapping 2..."/> <mapping resource="Some mapping 3..."/> </session-factory> </hibernate-configuration>
HibernateUtil.java
import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import java.util.Set; import org.hibernate.dialect.Dialect; import org.hibernate.Session;
public class HibernateUtil { private static final Configuration config = buildConfiguration(); private static final SessionFactory sessionFactory = buildSessionFactory(); private static final Set<String> reservedWords = buildKeyWords(); private static Configuration buildConfiguration() { try { return new Configuration().configure(); } catch ( Throwable ex ) { System.err.println( "Initial SessionFactory creation failed." + ex ); throw new ExceptionInInitializerError(ex); } } private static SessionFactory buildSessionFactory() { try { return config.buildSessionFactory(); } catch ( Throwable ex ) { System.err.println( "Initial SessionFactory creation failed." + ex ); throw new ExceptionInInitializerError(ex); } }
private static Set<String> buildKeyWords() { Dialect thisDialect; Set<String> retVal; // Initialize stuff retVal = null; try { thisDialect = Dialect.getDialect( config.getProperties() ); retVal = thisDialect.getKeywords(); } catch ( Exception e ) { e.printStackTrace(); } return( retVal ); } public static SessionFactory getSessionFactory() { return HibernateUtil.sessionFactory; } public static Set<String> getKeyWords() { return( HibernateUtil.reservedWords ); } }
|
|