Skip to content

Commit

Permalink
Adding hibernate back #13482
Browse files Browse the repository at this point in the history
  • Loading branch information
jgambarios committed Jan 30, 2018
1 parent 17cbaef commit 3d9787f
Show file tree
Hide file tree
Showing 47 changed files with 182 additions and 173 deletions.
10 changes: 3 additions & 7 deletions dotCMS/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
compile group: 'com.dotcms.lib', name: 'dot.concurrent', version:'1.3.4_2'
compile group: 'com.dotcms.lib', name: 'dot.core-renderer-modified', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.cos', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.counter-ejb', version:'ukv_3'
compile group: 'com.dotcms.lib', name: 'dot.counter-ejb', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.daisydiff', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.dnsjava', version:'2.0.8_2'
compile group: 'com.dotcms.lib', name: 'dot.drools-compiler', version:'3.0.5_2'
Expand All @@ -59,6 +59,7 @@ dependencies {
compile group: 'com.dotcms.lib', name: 'dot.hadoop-dev-core', version:'0.20.3_2'
compile group: 'com.dotcms.lib', name: 'dot.hadoop-dev-tools', version:'0.20.3_2'
compile group: 'com.hazelcast', name: 'hazelcast-all', version: '3.9.2'
compile group: 'com.dotcms.lib', name: 'dot.hibernate', version:'2.1.7_3'
compile group: 'com.dotcms.lib', name: 'dot.httpbridge', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.httpclient', version:'4.2.2_2'
compile group: 'com.dotcms.lib', name: 'dot.httpcore', version:'4.2.2_2'
Expand Down Expand Up @@ -131,6 +132,7 @@ dependencies {
compile group: 'com.dotcms.lib', name: 'dot.msnm', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.myspell', version:'ukv_2'
compile group: 'com.dotcms.lib', name: 'dot.nekohtml', version:'1.9.17_2'
compile group: 'com.dotcms.lib', name: 'dot.odmg', version:'ukv_3'
compile group: 'com.dotcms.lib', name: 'dot.org.eclipse.mylyn.wikitext.confluence.core', version:'1.8.0.I20120918-1109_2'
compile group: 'com.dotcms.lib', name: 'dot.org.eclipse.mylyn.wikitext.core', version:'1.8.0.I20120918-1109_2'
compile group: 'com.dotcms.lib', name: 'dot.org.eclipse.mylyn.wikitext.mediawiki.core', version:'1.8.0.I20120918-1109_2'
Expand Down Expand Up @@ -225,12 +227,6 @@ dependencies {
compile (group: 'sslext', name: 'sslext', version: '1.2-0'){
transitive = false
}
compile (group: 'hibernate', name: 'hibernate', version: '2.1.7c'){
transitive = false
}
compile ( group: 'odmg', name: 'odmg', version: '3.0'){
transitive = false
}
compile (group: 'cglib', name: 'cglib-nodep', version: '3.2.6'){
transitive = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.util.List;
import net.sf.hibernate.HibernateException;
import com.dotcms.repackage.net.sf.hibernate.HibernateException;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import net.sf.hibernate.Session;
import com.dotcms.repackage.net.sf.hibernate.Session;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import net.sf.hibernate.ObjectNotFoundException;
import com.dotcms.repackage.net.sf.hibernate.ObjectNotFoundException;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.count.CountRequestBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.hibernate.HibernateException;
import com.dotcms.repackage.net.sf.hibernate.HibernateException;


public class FixTaskFixStructureTable implements FixTask {
Expand Down Expand Up @@ -132,7 +132,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
if(o instanceof Inode){
Inode i = (Inode)o;
String type = i.getType();
String tableName = ((net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
String tableName = ((com.dotcms.repackage.net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
MaintenanceUtil.cleanInodeTableData(tableName, type);
//FixAssetsProcessStatus.addAError();
}
Expand All @@ -154,7 +154,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
if(o instanceof Inode){
Inode i = (Inode)o;
String type = i.getType();
String tableName = ((net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
String tableName = ((com.dotcms.repackage.net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
MaintenanceUtil.removeOphanedInodes(tableName, type);

}
Expand Down
24 changes: 12 additions & 12 deletions dotCMS/src/main/java/com/dotmarketing/db/DotSQLGeneratorTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.util.regex.Matcher;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
import com.dotcms.repackage.net.sf.hibernate.cfg.Configuration;
import com.dotcms.repackage.net.sf.hibernate.tool.hbm2ddl.SchemaExport;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

Expand Down Expand Up @@ -47,19 +47,19 @@ public void execute() throws BuildException {
Configuration cfg = new Configuration();
cfg.setProperty("hibernate.dialect", dialect);

if (dialect.equals("net.sf.hibernate.dialect.MySQLDialect")){
if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.MySQLDialect")){
cfg.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
}else if (dialect.equals("net.sf.hibernate.dialect.SybaseDialect")){
}else if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.SybaseDialect")){
cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
cfg.setProperty("hibernate.connection.driver_class", "net.sourceforge.jtds.jdbc.Driver");
}else if(dialect.equals("net.sf.hibernate.dialect.OracleDialect")){
}else if(dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.OracleDialect")){
cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
cfg.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
}else if(dialect.equals("net.sf.hibernate.dialect.PostgreSQLDialect")) {
}else if(dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.PostgreSQLDialect")) {
cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
cfg.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver");
}else if(dialect.equals("net.sf.hibernate.dialect.HSQLDialect")) {
}else if(dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.HSQLDialect")) {
cfg.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
}
Expand Down Expand Up @@ -105,20 +105,20 @@ public void execute() throws BuildException {
myLine = s.toString();
}
}
if (dialect.equals("net.sf.hibernate.dialect.PostgreSQLDialect")
|| dialect.equals("net.sf.hibernate.dialect.SybaseDialect")
|| dialect.equals("net.sf.hibernate.dialect.HSQLDialect")) {
if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.PostgreSQLDialect")
|| dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.SybaseDialect")
|| dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.HSQLDialect")) {
if (myLine.contains("varchar(123456789)")) {
myLine = myLine.replaceAll("varchar\\(123456789\\)", "text");
}
} else if (dialect.equals("net.sf.hibernate.dialect.OracleDialect")) {
} else if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.OracleDialect")) {
if (myLine.contains("varchar2(123456789)")) {
myLine = myLine.replaceAll("varchar2\\(123456789\\)", "clob");
}
else if (myLine.contains(" long ") || myLine.contains(" long,")) {
myLine = myLine.replaceAll("long", "nclob");
}
} else if (dialect.equals("net.sf.hibernate.dialect.MySQLDialect")) {
} else if (dialect.equals("com.dotcms.repackage.net.sf.hibernate.dialect.MySQLDialect")) {
if (myLine.contains("varchar(123456789)")) {
myLine = myLine.replaceAll("varchar\\(123456789\\)", "longtext");
}
Expand Down
34 changes: 17 additions & 17 deletions dotCMS/src/main/java/com/dotmarketing/db/HibernateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import net.sf.hibernate.CallbackException;
import net.sf.hibernate.FlushMode;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Interceptor;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.ObjectNotFoundException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.cfg.Mappings;
import net.sf.hibernate.type.Type;
import com.dotcms.repackage.net.sf.hibernate.CallbackException;
import com.dotcms.repackage.net.sf.hibernate.FlushMode;
import com.dotcms.repackage.net.sf.hibernate.HibernateException;
import com.dotcms.repackage.net.sf.hibernate.Interceptor;
import com.dotcms.repackage.net.sf.hibernate.MappingException;
import com.dotcms.repackage.net.sf.hibernate.ObjectNotFoundException;
import com.dotcms.repackage.net.sf.hibernate.Query;
import com.dotcms.repackage.net.sf.hibernate.Session;
import com.dotcms.repackage.net.sf.hibernate.SessionFactory;
import com.dotcms.repackage.net.sf.hibernate.cfg.Configuration;
import com.dotcms.repackage.net.sf.hibernate.cfg.Mappings;
import com.dotcms.repackage.net.sf.hibernate.type.Type;

/**
* This class provides a great number of utility methods that allow developers to interact with
Expand Down Expand Up @@ -641,27 +641,27 @@ private static void buildSessionFactory() throws DotHibernateException{
cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
cfg.addResource("com/dotmarketing/beans/DotCMSId_NOSQLGEN.hbm.xml");
getPluginsHBM("Id",cfg);
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.MySQLDialect");
cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.MySQLDialect");
} else if (DbConnectionFactory.isPostgres()) {
cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
cfg.addResource("com/dotmarketing/beans/DotCMSSeq_NOSQLGEN.hbm.xml");
getPluginsHBM("Seq",cfg);
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.PostgreSQLDialect");
cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.PostgreSQLDialect");
} else if (DbConnectionFactory.isMsSql()) {
cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
cfg.addResource("com/dotmarketing/beans/DotCMSId_NOSQLGEN.hbm.xml");
getPluginsHBM("Id",cfg);
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.SQLServerDialect");
cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.SQLServerDialect");
} else if (DbConnectionFactory.isOracle()) {
cfg.addResource("com/dotmarketing/beans/DotCMSSeq.hbm.xml");
cfg.addResource("com/dotmarketing/beans/DotCMSSeq_NOSQLGEN.hbm.xml");
getPluginsHBM("Seq",cfg);
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.OracleDialect");
cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.OracleDialect");
} else if (DbConnectionFactory.isH2()) {
cfg.addResource("com/dotmarketing/beans/DotCMSId.hbm.xml");
cfg.addResource("com/dotmarketing/beans/DotCMSId_NOSQLGEN.hbm.xml");
getPluginsHBM("Id",cfg);
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.HSQLDialect");
cfg.setProperty("hibernate.dialect", "com.dotcms.repackage.net.sf.hibernate.dialect.HSQLDialect");
}

cfg.setInterceptor(new NoDirtyFlushInterceptor());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.dotmarketing.db;

import net.sf.hibernate.cfg.DefaultNamingStrategy;
import com.dotcms.repackage.net.sf.hibernate.cfg.DefaultNamingStrategy;

public class LowercaseNamingStrategy extends DefaultNamingStrategy {

Expand Down
19 changes: 16 additions & 3 deletions dotCMS/src/main/java/com/dotmarketing/db/NoCacheProvider.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.dotmarketing.db;

import java.util.Properties;
import net.sf.hibernate.cache.Cache;
import net.sf.hibernate.cache.CacheException;
import net.sf.hibernate.cache.CacheProvider;

import com.dotcms.repackage.net.sf.hibernate.cache.Cache;
import com.dotcms.repackage.net.sf.hibernate.cache.CacheException;
import com.dotcms.repackage.net.sf.hibernate.cache.CacheProvider;

public class NoCacheProvider implements CacheProvider {

Expand All @@ -17,4 +18,16 @@ public long nextTimestamp() {
return System.currentTimeMillis() / 100;
}

@Override
public void start(Properties arg0) throws CacheException {


}

@Override
public void stop() {


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.hibernate.ObjectNotFoundException;
import com.dotcms.repackage.net.sf.hibernate.ObjectNotFoundException;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.dotmarketing.factories;

import java.io.Serializable;
import net.sf.hibernate.engine.SessionImplementor;
import net.sf.hibernate.id.IdentifierGenerator;
import com.dotcms.repackage.net.sf.hibernate.engine.SessionImplementor;
import com.dotcms.repackage.net.sf.hibernate.id.IdentifierGenerator;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.hibernate.HibernateException;
import com.dotcms.repackage.net.sf.hibernate.HibernateException;


public class FixTask00001CheckAssetsMissingIdentifiers implements FixTask {
Expand Down Expand Up @@ -132,7 +132,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
if(o instanceof Inode){
Inode i = (Inode)o;
String type = i.getType();
String tableName = ((net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
String tableName = ((com.dotcms.repackage.net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
MaintenanceUtil.cleanInodeTableData(tableName, type);
//FixAssetsProcessStatus.addAError();
}
Expand All @@ -154,7 +154,7 @@ public List <Map <String,Object>> executeFix() throws DotDataException, DotRunti
if(o instanceof Inode){
Inode i = (Inode)o;
String type = i.getType();
String tableName = ((net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
String tableName = ((com.dotcms.repackage.net.sf.hibernate.persister.AbstractEntityPersister)map.get(x)).getTableName();
MaintenanceUtil.removeOphanedInodes(tableName, type);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import net.sf.hibernate.ObjectNotFoundException;
import com.dotcms.repackage.net.sf.hibernate.ObjectNotFoundException;
import org.apache.commons.beanutils.BeanUtils;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,9 @@ private void createXMLFiles() throws ServletException, IOException, DotDataExcep

//http://jira.dotmarketing.net/browse/DOTCMS-6059
if(clazz.equals(DashboardSummary404.class) || clazz.equals(DashboardUserPreferences.class)){
_xstream.addDefaultImplementation(net.sf.hibernate.collection.Set.class, java.util.Set.class);
_xstream.addDefaultImplementation(net.sf.hibernate.collection.List.class, java.util.List.class);
_xstream.addDefaultImplementation(net.sf.hibernate.collection.Map.class, java.util.Map.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Set.class, java.util.Set.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.List.class, java.util.List.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Map.class, java.util.Map.class);
Mapper mapper = _xstream.getMapper();
_xstream.registerConverter(new HibernateCollectionConverter(mapper));
_xstream.registerConverter(new HibernateMapConverter(mapper));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
import java.util.zip.ZipOutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import net.sf.hibernate.HibernateException;
import com.dotcms.repackage.net.sf.hibernate.HibernateException;
import org.quartz.JobExecutionContext;

/**
Expand Down Expand Up @@ -481,9 +481,9 @@ public void createXMLFiles() throws ServletException, IOException, DotDataExcept

//http://jira.dotmarketing.net/browse/DOTCMS-6059
if(clazz.equals(DashboardSummary404.class) || clazz.equals(DashboardUserPreferences.class)){
_xstream.addDefaultImplementation(net.sf.hibernate.collection.Set.class, java.util.Set.class);
_xstream.addDefaultImplementation(net.sf.hibernate.collection.List.class, java.util.List.class);
_xstream.addDefaultImplementation(net.sf.hibernate.collection.Map.class, java.util.Map.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Set.class, java.util.Set.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.List.class, java.util.List.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Map.class, java.util.Map.class);
Mapper mapper = _xstream.getMapper();
_xstream.registerConverter(new HibernateCollectionConverter(mapper));
_xstream.registerConverter(new HibernateMapConverter(mapper));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.dotmarketing.util.InodeUtils;
import java.util.ArrayList;
import java.util.List;
import net.sf.hibernate.ObjectNotFoundException;
import com.dotcms.repackage.net.sf.hibernate.ObjectNotFoundException;
import org.apache.commons.beanutils.BeanUtils;

public class HostVariableFactoryImpl extends HostVariableFactory{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.thoughtworks.xstream.converters.collections.CollectionConverter;
import com.thoughtworks.xstream.mapper.Mapper;
import net.sf.hibernate.collection.List;
import net.sf.hibernate.collection.Set;
import com.dotcms.repackage.net.sf.hibernate.collection.List;
import com.dotcms.repackage.net.sf.hibernate.collection.Set;

public class HibernateCollectionConverter extends CollectionConverter {
public HibernateCollectionConverter(Mapper mapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.thoughtworks.xstream.converters.collections.MapConverter;
import com.thoughtworks.xstream.mapper.Mapper;
import net.sf.hibernate.collection.Map;
import com.dotcms.repackage.net.sf.hibernate.collection.Map;

public class HibernateMapConverter extends MapConverter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.persister.AbstractEntityPersister;
import com.dotcms.repackage.net.sf.hibernate.HibernateException;
import com.dotcms.repackage.net.sf.hibernate.persister.AbstractEntityPersister;

/**
* This utility is part of the {@link Task00004LoadStarter} task, which fills
Expand Down
Loading

0 comments on commit 3d9787f

Please sign in to comment.