My hibernate config file is not placed in the default
(root) folder so I'm using the meta tag in the class
tag of the mapping files (e.g. <meta
attribute="config-file">path/to/my/hibernate.cfg.xml</meta>)
When I want to get the session in the following example:
_RootDAO.initialize("path/to/my/configfile/hibernate.cfg.xml");
ObjectRoleDAO objectRoleDAO = new ObjectRoleDAO();
Session s = objectRoleDAO.getSession();
the following exception is thrown:
java.lang.RuntimeException: The session factory for
'path/to/my/hibernate.cfg.xml' has not been initialized
(or an error occured during initialization)
The sessionFactory is null when it is set in the
_BaseRootDAO using a configFileName:
protected static void setSessionFactory (String
configFileName, SessionFactory sf) {
if (null == configFileName) {
sessionFactory = sf;
}
else {
if (null == sessionFactoryMap) sessionFactoryMap =
new HashMap<String, SessionFactory>();
sessionFactoryMap.put(
configFileName,
sessionFactory);
}
}
Attached you find a patch for the snippet file
reponsible for this issue.
patch for _BaseRootDAO-Snippet