-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Fri Dec 17, 2010 1:34 pm 
Newbie

Joined: Fri Dec 17, 2010 1:22 pm
Posts: 5
After 2 days searching for the error i found it and unfortunatly i can not fix it, cause it's in org.hibernate.cfg.SettingsFactory.

The root of my prob is, that i have to use a jdbc driver that does not support meta.getDatabaseMajorVersion().

Because of that, the code in SettingsFactory.buildSettings produces a NullpointerException:
Code:
try {
            Connection conn = connections.getConnection();
            try {
               DatabaseMetaData meta = conn.getMetaData();
               log.info( "Database ->\n" +
                     "       name : " + meta.getDatabaseProductName() + '\n' +
                     "    version : " +  meta.getDatabaseProductVersion() + '\n' +
                     "      major : " + meta.getDatabaseMajorVersion() + '\n' +
                     "      minor : " + meta.getDatabaseMinorVersion()
               );
               log.info( "Driver ->\n" +
                     "       name : " + meta.getDriverName() + '\n' +
                     "    version : " + meta.getDriverVersion() + '\n' +
                     "      major : " + meta.getDriverMajorVersion() + '\n' +
                     "      minor : " + meta.getDriverMinorVersion()
               );

               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 );               <-- Exception of getDatabaseMajorVersion will end here.
            }
            finally {
               connections.closeConnection( conn );
            }
         }
         catch ( SQLException sqle ) {
            log.warn( "Could not obtain connection to query metadata", sqle );
            dialect = DialectFactory.buildDialect( props );
         }
         catch ( UnsupportedOperationException uoe ) {
            // user supplied JDBC connections
            dialect = DialectFactory.buildDialect( props );
         }
      }
// dialect == null

// #169
properties.putAll( dialect.getDefaultProperties() );  <-- NullpointerException


My "dirty hack" to overcome this problem is to use the in-line documented code snippet @ line#111.

Is this a known issue? haven't found it in jira.


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Dec 23, 2010 5:52 am 
Newbie

Joined: Fri Dec 17, 2010 1:22 pm
Posts: 5
seam like the temp config property is part of the SettingsFactory since 3.3.

For anyone experiencing problems with Dialect creation because of the jdbc-driver
setting the temp property may help.

Code:
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>


However the property is not documented (just inline) and i'm sure, or lets say i hope, it
will be remove/replaced in near future.


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Dec 23, 2010 5:56 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
After 2 days searching for the error i found it and unfortunatly i can not fix it, cause it's in org.hibernate.cfg.SettingsFactory.

Actually it should be easy for you to fix it, being open source. Provide a patch, open a JIRA issue, we will include it in the next release.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Dec 23, 2010 6:29 am 
Newbie

Joined: Fri Dec 17, 2010 1:22 pm
Posts: 5
i fixed the problem with hibernate.temp.use_jdbc_metadata_defaults which is reported in
- http://opensource.atlassian.com/project ... e/HHH-2372.

other issues that can be fixed with use_jdbc_metadata_defaults
http://opensource.atlassian.com/project ... se/HHH-514
http://opensource.atlassian.com/project ... se/HHH-517

the cleanest fix is to including the config property in the documenation :)


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Dec 23, 2010 6:37 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
ok, but now as you have shown me this bug was there in 2005 and only relevant to "obsolete drivers", how stone aged could we define this driver now in 2011 ? I guess you're having way more trouble if you don't update it, even the old oracle jdbc drivers are very bad.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Dec 23, 2010 6:44 am 
Newbie

Joined: Fri Dec 17, 2010 1:22 pm
Posts: 5
definitely true.
our customer is using a unify sqlbase db and their newest driver is definitly obsolete but i have no choise :(


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Feb 10, 2011 5:55 am 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
This is not just a problem of older database drivers. I have an Oracle XE 10g database here that throws an SQL Exception when asked for the database major and/or minor version. This completely breaks usage of Hibernate 3.6 with that database. Just because of some newly introduced log message!


Top
 Profile  
 
 Post subject: Re: [3.6] NullpointerExceptin in SettingsFactory
PostPosted: Thu Feb 10, 2011 6:34 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
etwc, thanks for letting us know. care to make a patch? I'd catch the exception and return an empty string instead, logging a warning.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.