I had to replace the Hibernate call Connection conn = sessionImpl.connection()
with the following, due to ".connection()" being deprecated in Hibernate. ref: session.connection() deprecated on Hibernate? A try;catch; is required, as doWork()
throws a HibernateException.
try {
session.doWork(
new Work() {
public void execute(Connection connection) throws SQLException
{
doSomething(connection);
}
}
);
} catch (HibernateException e) {
}
The problem is, I'm getting the following in Eclipse:
No exception of type HibernateException can be thrown; an exception type must be a subclass of Throwable
As far as I can tell, HibernateException chains back to Throwable, so I don't know what it's talking about.
I'm using hibernate-core 6.1.0
Any suggestions would be greatly appreciated.
Update/Fix
So it turns out I didn't have the right library on my classpath. HibernateException extends jakarta.persistence.PersistenceException I did have the following in my POM
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<version>2.2.3</version>
</dependency>
But I did NOT have the persistence API in my POM
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.1.0</version>
</dependency>
I had checked my POM before, but didn't realize there was a difference between the two. Thanks rzwitserloot for enticing me to look again.