[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5017) "SettingsFactory" no longer checks for presence of "supportsGetGeneratedKeys" before calling it

Weinan Xiong (JIRA) noreply at atlassian.com
Fri Jun 11 14:12:58 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37406#action_37406 ] 

Weinan Xiong commented on HHH-5017:
-----------------------------------

We are using Hibernate 3.5.2. We have this problem. I did check the source code for this newest version. Just like Steve said, 'SettringsFactory no longer checks for presence of supportsGetGeneratedKeys before calling it.

The following is the code from the SettingsFactory. As you can see, the method, supportsGetGeneratedKeys(), is called without any checking unlike the previous versions.

                boolean useJdbcMetadata = PropertiesHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", props, true );
		if ( useJdbcMetadata ) {
			try {
				Connection conn = connections.getConnection();
				try {
					DatabaseMetaData meta = conn.getMetaData();
					log.info( "RDBMS: " + meta.getDatabaseProductName() + ", version: " + meta.getDatabaseProductVersion() );
					log.info( "JDBC driver: " + meta.getDriverName() + ", version: " + meta.getDriverVersion() );

					dialect = DialectFactory.buildDialect( props, conn );
					jdbcSupport = JdbcSupportLoader.loadJdbcSupport( conn );

					metaSupportsScrollable = meta.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
					metaSupportsBatchUpdates = meta.supportsBatchUpdates();
					metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
					metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
					metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
				}
				catch ( SQLException sqle ) {
					log.warn( "Could not obtain connection metadata", sqle );
				}
				finally {
					connections.closeConnection( conn );
				}
			}


> "SettingsFactory" no longer checks for presence of "supportsGetGeneratedKeys" before calling it
> -----------------------------------------------------------------------------------------------
>
>                 Key: HHH-5017
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5017
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.2
>            Reporter: Steve Perkins
>
> A number of users are experiencing Hibernate failures when using various combinations of Oracle JDBC driver versions and JDK versions.  A sample stacktrace is below:
> Initial SessionFactory Creaion Failed.java.lang.AbstractMethodError: oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at HibernateUtil.buildSessionFactory(HibernateUtil.java:27)
> at HibernateUtil.<clinit>(HibernateUtil.java:17)
> at EvenManager.createAndStoreEvent(EvenManager.java:33)
> at EvenManager.main(EvenManager.java:26)
> Caused by: java.lang.AbstractMethodError: oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z
> at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:123)
> at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
> at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
> at HibernateUtil.buildSessionFactory(HibernateUtil.java:23)
> ... 3 more
> The basic issue is that the "supportsGetGeneratedKeys" method does not exist on the "oracle.jdbc.driver.OracleDatabaseMetaData" JDBC driver class for many versions of Oracle.  Even if you use the "hibernate.jdbc.use_get_generated_keys" config property, Hibernate still makes a call to that method and execution still fails.
> Up until version 3.2.7.GA of Hibernate, the code checked for the presence of "supportsGetGeneratedKeys" prior to calling it.  The problem emerged with version 3.3.2.GA, where now Hibernate just calls the method without first verifying that it exists.  If there was no functional reason for removing this safety-check, can we please re-insert it to prevent such failures?
> A discussion of this issue can be found on the forums at:  https://forum.hibernate.org/viewtopic.php?f=1&t=1002210&p=2427193#p2427193

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list