我有一个类如下,当我运行 PMD 规则时,我得到一个 PMD Alert 类型AvoidThrowingRawExceptionTypes
。我无法解决这个问题,因为当我在构造函数 throws 子句中添加任何其他异常类型时,我遇到了错误
new PersistenceManager(CommonConstants.IP_DB)
如何解决这个问题?有人可以帮我吗?
public class PersistenceManager implements CommonConstants {
.....
/**
* Stores the persistence mgr for IPMasterData_DB
*/
public static PersistenceManager IPMasterData_DB = new PersistenceManager(
CommonConstants.IP_DB);
/**
* Configures the data source according to the resource passed.
*
* @param dbName
* Databasename
*/
protected PersistenceManager(String dbName) throws Exception{
String resourceName = "";
if (LOGGER == null) {
LOGGER = Logger.getLogger(PersistenceManager.class);
}
try {
resourceName = getConfigFileName(dbName);
this.sessionFactory = new Configuration().configure(resourceName)
.setProperty("hibernate.jdbc.batch_size",
PersistenceManager.getBatchSize(dbName))
.buildSessionFactory();
} catch (HibernateException ex) {
ex.printStackTrace();
LOGGER
.error("Exception building SessionFactory for configKey ",
ex);
throw new RuntimeException(ErrorConstants.SESSIONFACTORY_BUILD, ex);
}
}
}