public void init() {
try {
ClassLoader classLoader = getClass().getClassLoader();
Configuration cfg = new Configuration();
String[] configs = StringUtil.split(
SystemProperties.get("hibernate.configs"));
for (int i = 0; i < configs.length; i++) {
try {
InputStream is =
classLoader.getResourceAsStream(configs[i]);
if (is != null) {
cfg = cfg.addInputStream(is);
is.close();
}
}
catch (Exception e) {
Logger.error(this,e.getMessage(),e);
}
}
cfg.setProperties(SystemProperties.getProperties());
//http://jira.dotmarketing.net/browse/DOTCMS-4937
if (DbConnectionFactory.isMySql()) {
cfg.setNamingStrategy(new LowercaseNamingStrategy());
Table liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.CompanyHBM.class).getTable();
liferayTable.setName("company");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.AddressHBM.class).getTable();
liferayTable.setName("address");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.ImageHBM.class).getTable();
liferayTable.setName("image");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.PasswordTrackerHBM.class).getTable();
liferayTable.setName("passwordtracker");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.PortletHBM.class).getTable();
liferayTable.setName("portlet");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.PortletPreferencesHBM.class).getTable();
liferayTable.setName("portletpreferences");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.ReleaseHBM.class).getTable();
liferayTable.setName("release_");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.UserHBM.class).getTable();
liferayTable.setName("user_");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.UserTrackerHBM.class).getTable();
liferayTable.setName("usertracker");
liferayTable = cfg.getClassMapping(com.liferay.portal.ejb.UserTrackerPathHBM.class).getTable();
liferayTable.setName("usertrackerpath");
liferayTable = cfg.getClassMapping(com.liferay.portlet.admin.ejb.AdminConfigHBM.class).getTable();
liferayTable.setName("adminconfig");
liferayTable = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsChoiceHBM.class).getTable();
liferayTable.setName("pollschoice");
liferayTable = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsDisplayHBM.class).getTable();
liferayTable.setName("pollsdisplay");
liferayTable = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsQuestionHBM.class).getTable();
liferayTable.setName("pollsquestion");
liferayTable = cfg.getClassMapping(com.liferay.portlet.polls.ejb.PollsVoteHBM.class).getTable();
liferayTable.setName("pollsvote");
liferayTable = cfg.getClassMapping(com.dotcms.repackage.com.liferay.counter.ejb.CounterHBM.class).getTable();
liferayTable.setName("counter");
}
setSessionFactory(cfg.buildSessionFactory());
}
catch (Exception e) {
Logger.error(this,e.getMessage(),e);
}
}