If you want the un-proxied version of the JBDC Connection, then unwrap() it. That is the standard pattern for dealing with JDBC objects.
And no, this is not a backwards compatibility problem. On Fri 15 Feb 2013 06:52:33 AM CST, amit shah wrote: > I think the defect description was not clear probably. The issue is > not related to backward compatibility of hibernate with other > frameworks (spring in this case). It is with hibernate 4.1.9 vs 3.6.0. > > Hibernate 3.6.0 threw checked exceptions (SQLException) while 4.1.9 > throws an unchecked exception (SQLGrammerException). > > > On Fri, Feb 15, 2013 at 5:28 PM, Sanne Grinovero <sa...@hibernate.org > <mailto:sa...@hibernate.org>> wrote: > > Hi Amit, > please use the developer list for such concerns, which I've added > in CC. > > Personally I don't think your issue is valid, but I'll leave that to > the other team members to decide. > We never promised backwards compatibility with other frameworks when > upgrading from Hibernate 3 to 4, it is likely that you will need to > make some adjustments in configurations; also I'm not a Spring expert > but from what you describe it looks to me it's not a good idea to use > the "spring jdbc template" as JDBC and Hibernate are two different > things. > > Sanne > > On 15 February 2013 11:41, amit shah <amits...@gmail.com > <mailto:amits...@gmail.com>> wrote: > > Hello Steve/Sanne, > > While upgrading to hibernate 4.1.9 from 3.6.0 I > am facing an > > blocking issue for which I would appreciate if you can provide > your inputs. > > The issue was logged on jira forum but it didn't get much > attention. I will > > paste it here once. Kindly let me know your thoughts. > > > > > > Description > > > > I upgraded my project with hibernate 4.1.9 and spring 3.2.1 and > noticed that > > hibernate throws RuntimeExceptions instead of checked exception > in the > > earlier version (3.6.0 final was the one we used earlier). The > code use case > > is as below. > > > > We use spring jdbc template for executing jdbc queries and the > application > > is configured to use JPA (JPATransactionManager and JPADialect) > for mapped > > entities. When executing a query which could throw a exception > for e.g. a > > select query on a table that does not exist, hibernate now > proxies the jdbc > > statements and throws a SQLGrammerException (extends > RuntimeException) > > instead of a checked exception - SQLException. > > > > Since spring catch's SQLException, the code no longer executes > the catch > > block and fails with an exception. > > > > Attached a sample java program to reproduce the issue. Please > execute the > > main method of the ExceptionHandlingTask class. It starts a spring > > transaction and executes a query on a non existing table. > > > > Spring and hibernate jars must be included in the classpath. > > > > Thank you, > > Amit. > > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev