Do it like this for HBM:
String mapping = dao.getMappping();
if (mapping == null) {
throw new DAOException(DAOException.TYPE.SESSION_FACTORY, "Mapping not available from class: " + c.getName());
}
configuration.addResource(
mapping,
getClass().getClassLoader()
);
or for JPA mappings files:
String mapping = dao.getMappping();
if (mapping == null) {
throw new DAOException(DAOException.TYPE.SESSION_FACTORY, "Mapping not available from class: " + c.getName());
}
try (InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream( xmlFile )) {
configuration.addInputStream( is );
}
catch (IOException e) {
throw new IllegalArgumentException( e );
}