HHH-6971 Migrates logging to JBoss logging.
This commit is contained in:
parent
ee96098ead
commit
619c9ed515
|
@ -14,9 +14,6 @@ dependencies {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
compile( libraries.slf4j_log4j12) {
|
|
||||||
transitive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
testCompile( libraries.junit )
|
testCompile( libraries.junit )
|
||||||
testCompile( project(':hibernate-testing') )
|
testCompile( project(':hibernate-testing') )
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.hibernate.spatial;
|
||||||
|
|
||||||
|
import org.jboss.logging.BasicLogger;
|
||||||
|
import org.jboss.logging.MessageLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karel Maesen, Geovise BVBA
|
||||||
|
* creation-date: 1/14/12
|
||||||
|
*/
|
||||||
|
@MessageLogger(projectCode = "HS")
|
||||||
|
public interface Log extends BasicLogger {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.hibernate.spatial;
|
||||||
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A static factory for <code>Log</code>s.
|
||||||
|
*
|
||||||
|
* <p>This class is based on hibernate-ogm LoggerFactory class.</p>
|
||||||
|
*
|
||||||
|
* @author Karel Maesen, Geovise BVBA
|
||||||
|
* creation-date: 1/14/12
|
||||||
|
*/
|
||||||
|
public class LogFactory {
|
||||||
|
|
||||||
|
public static Log make() {
|
||||||
|
Throwable t = new Throwable();
|
||||||
|
StackTraceElement directCaller = t.getStackTrace()[1];
|
||||||
|
return Logger.getMessageLogger(Log.class, directCaller.getClassName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -27,6 +27,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.spatial.cfg;
|
package org.hibernate.spatial.cfg;
|
||||||
|
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentException;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.dom4j.io.SAXReader;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
|
import org.hibernate.spatial.LogFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -34,15 +42,6 @@ import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.dom4j.Document;
|
|
||||||
import org.dom4j.DocumentException;
|
|
||||||
import org.dom4j.Element;
|
|
||||||
import org.dom4j.io.SAXReader;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration information for the Hibernate Spatial Extension.
|
* Configuration information for the Hibernate Spatial Extension.
|
||||||
*
|
*
|
||||||
|
@ -55,7 +54,7 @@ public class HSConfiguration extends Properties {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger( HSConfiguration.class );
|
private static Log logger = LogFactory.make();
|
||||||
|
|
||||||
private String source = "runtime configuration object";
|
private String source = "runtime configuration object";
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,6 @@ import org.hibernate.spatial.helper.PropertyFileReader;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -148,8 +146,7 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements
|
||||||
|
|
||||||
private final static String CONNECTION_FINDER_PROPERTY = "CONNECTION-FINDER";
|
private final static String CONNECTION_FINDER_PROPERTY = "CONNECTION-FINDER";
|
||||||
|
|
||||||
private final static Logger log = LoggerFactory
|
private final static Log LOG = LogFactory.make();
|
||||||
.getLogger(OracleSpatial10gDialect.class);
|
|
||||||
|
|
||||||
private String OGC_STRICT = "OGC_STRICT";
|
private String OGC_STRICT = "OGC_STRICT";
|
||||||
|
|
||||||
|
@ -271,7 +268,7 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements
|
||||||
@Override
|
@Override
|
||||||
public String getTypeName(int code, long length, int precision, int scale) throws HibernateException {
|
public String getTypeName(int code, long length, int precision, int scale) throws HibernateException {
|
||||||
if (code == 3000) return "SDO_GEOMETRY";
|
if (code == 3000) return "SDO_GEOMETRY";
|
||||||
return super.getTypeName(code, length, precision, scale); //To change body of overridden methods use File | Settings | File Templates.
|
return super.getTypeName(code, length, precision, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -533,7 +530,7 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements
|
||||||
URL propfile = loader.getResource(propfileLoc);
|
URL propfile = loader.getResource(propfileLoc);
|
||||||
if (propfile != null) {
|
if (propfile != null) {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
log.info("properties file found: " + propfile);
|
LOG.info("properties file found: " + propfile);
|
||||||
try {
|
try {
|
||||||
loader.getResource(getClass().getCanonicalName());
|
loader.getResource(getClass().getCanonicalName());
|
||||||
is = propfile.openStream();
|
is = propfile.openStream();
|
||||||
|
@ -549,15 +546,15 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements
|
||||||
ConnectionFinder cf = (ConnectionFinder) clazz
|
ConnectionFinder cf = (ConnectionFinder) clazz
|
||||||
.newInstance();
|
.newInstance();
|
||||||
OracleJDBCTypeFactory.setConnectionFinder(cf);
|
OracleJDBCTypeFactory.setConnectionFinder(cf);
|
||||||
log.info("Setting ConnectionFinder to " + ccn);
|
LOG.info("Setting ConnectionFinder to " + ccn);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
log.warn("Tried to set ConnectionFinder to " + ccn
|
LOG.warn("Tried to set ConnectionFinder to " + ccn
|
||||||
+ ", but class not found.");
|
+ ", but class not found.");
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
log.warn("Tried to set ConnectionFinder to " + ccn
|
LOG.warn("Tried to set ConnectionFinder to " + ccn
|
||||||
+ ", but couldn't instantiate.");
|
+ ", but couldn't instantiate.");
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
log
|
LOG
|
||||||
.warn("Tried to set ConnectionFinder to "
|
.warn("Tried to set ConnectionFinder to "
|
||||||
+ ccn
|
+ ccn
|
||||||
+ ", but got IllegalAcessException on instantiation.");
|
+ ", but got IllegalAcessException on instantiation.");
|
||||||
|
@ -565,7 +562,7 @@ public class OracleSpatial10gDialect extends Oracle10gDialect implements
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Problem reading properties file " + e);
|
LOG.warn("Problem reading properties file " + e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.spatial.helper;
|
package org.hibernate.spatial.helper;
|
||||||
|
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
|
import org.hibernate.spatial.LogFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -38,9 +41,6 @@ import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to read settings and properties files.
|
* Helper class to read settings and properties files.
|
||||||
*
|
*
|
||||||
|
@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class PropertyFileReader {
|
public class PropertyFileReader {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger( PropertyFileReader.class );
|
private static final Log LOG = LogFactory.make();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pattern for comment lines. If it matches, it is a comment.
|
* pattern for comment lines. If it matches, it is a comment.
|
||||||
|
@ -97,7 +97,7 @@ public class PropertyFileReader {
|
||||||
this.is.close();
|
this.is.close();
|
||||||
}
|
}
|
||||||
catch ( IOException e ) {
|
catch ( IOException e ) {
|
||||||
log.warn( "Exception when closing PropertyFileReader: " + e );
|
LOG.warn( "Exception when closing PropertyFileReader: " + e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
package org.hibernate.spatial.jts;
|
package org.hibernate.spatial.jts;
|
||||||
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MGeometryFactory;
|
import org.hibernate.spatial.jts.mgeom.MGeometryFactory;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A static utility class
|
* A static utility class
|
||||||
|
@ -39,8 +37,6 @@ import org.slf4j.LoggerFactory;
|
||||||
*/
|
*/
|
||||||
public class JTS {
|
public class JTS {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger( JTS.class );
|
|
||||||
|
|
||||||
private static MGeometryFactory defaultGeomFactory = new MGeometryFactory();
|
private static MGeometryFactory defaultGeomFactory = new MGeometryFactory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,13 +29,13 @@ import com.vividsolutions.jts.geom.Geometry;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
|
import org.hibernate.spatial.LogFactory;
|
||||||
import org.hibernate.spatial.SpatialFunction;
|
import org.hibernate.spatial.SpatialFunction;
|
||||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||||
import org.hibernate.testing.Skip;
|
import org.hibernate.testing.Skip;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -47,10 +47,10 @@ import java.util.Map;
|
||||||
@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect")
|
@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect")
|
||||||
public class TestSpatialFunctions extends SpatialFunctionalTestCase {
|
public class TestSpatialFunctions extends SpatialFunctionalTestCase {
|
||||||
|
|
||||||
private static Logger LOGGER = LoggerFactory.getLogger( TestSpatialFunctions.class );
|
private static Log LOG = LogFactory.make();
|
||||||
|
|
||||||
protected Logger getLogger() {
|
protected Log getLogger() {
|
||||||
return LOGGER;
|
return LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -29,14 +29,14 @@ import org.hibernate.Criteria;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.criterion.Criterion;
|
import org.hibernate.criterion.Criterion;
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
|
import org.hibernate.spatial.LogFactory;
|
||||||
import org.hibernate.spatial.SpatialFunction;
|
import org.hibernate.spatial.SpatialFunction;
|
||||||
import org.hibernate.spatial.criterion.SpatialRestrictions;
|
import org.hibernate.spatial.criterion.SpatialRestrictions;
|
||||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||||
import org.hibernate.testing.Skip;
|
import org.hibernate.testing.Skip;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -48,10 +48,10 @@ import static org.junit.Assert.fail;
|
||||||
@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect")
|
@Skip(condition = SpatialDialectMatcher.class,message = "No Spatial Dialect")
|
||||||
public class TestSpatialRestrictions extends SpatialFunctionalTestCase {
|
public class TestSpatialRestrictions extends SpatialFunctionalTestCase {
|
||||||
|
|
||||||
private static Logger LOGGER = LoggerFactory.getLogger( TestSpatialRestrictions.class );
|
private static Log LOG = LogFactory.make();
|
||||||
|
|
||||||
protected Logger getLogger() {
|
protected Log getLogger() {
|
||||||
return LOGGER;
|
return LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -222,7 +222,7 @@ public class TestSpatialRestrictions extends SpatialFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals( cnt, list.size() );
|
assertEquals( cnt, list.size() );
|
||||||
LOGGER.info( String.format( "Found %d objects within testsuite-suite polygon.", cnt ) );
|
LOG.info( String.format( "Found %d objects within testsuite-suite polygon.", cnt ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean findInList(Integer id, List<GeomEntity> list) {
|
private boolean findInList(Integer id, List<GeomEntity> list) {
|
||||||
|
|
|
@ -30,13 +30,13 @@ import com.vividsolutions.jts.io.ParseException;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
|
import org.hibernate.spatial.LogFactory;
|
||||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||||
import org.hibernate.spatial.testing.TestDataElement;
|
import org.hibernate.spatial.testing.TestDataElement;
|
||||||
import org.hibernate.testing.Skip;
|
import org.hibernate.testing.Skip;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,10 +53,10 @@ import static org.junit.Assert.assertTrue;
|
||||||
@Skip(condition = SpatialDialectMatcher.class, message = "No Spatial Dialect")
|
@Skip(condition = SpatialDialectMatcher.class, message = "No Spatial Dialect")
|
||||||
public class TestStoreRetrieve extends SpatialFunctionalTestCase {
|
public class TestStoreRetrieve extends SpatialFunctionalTestCase {
|
||||||
|
|
||||||
private static Logger LOGGER = LoggerFactory.getLogger(TestStoreRetrieve.class);
|
private static Log LOG = LogFactory.make();
|
||||||
|
|
||||||
protected Logger getLogger() {
|
protected Log getLogger() {
|
||||||
return LOGGER;
|
return LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepareTest(){
|
public void prepareTest(){
|
||||||
|
|
|
@ -30,8 +30,8 @@ import com.vividsolutions.jts.geom.Point;
|
||||||
import com.vividsolutions.jts.geom.Polygon;
|
import com.vividsolutions.jts.geom.Polygon;
|
||||||
import com.vividsolutions.jts.io.ParseException;
|
import com.vividsolutions.jts.io.ParseException;
|
||||||
import com.vividsolutions.jts.io.WKTReader;
|
import com.vividsolutions.jts.io.WKTReader;
|
||||||
import org.slf4j.Logger;
|
import org.hibernate.spatial.Log;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.hibernate.spatial.LogFactory;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -48,7 +48,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractExpectationsFactory {
|
public abstract class AbstractExpectationsFactory {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger( AbstractExpectationsFactory.class );
|
private static final Log LOG = LogFactory.make();
|
||||||
|
|
||||||
public final static String TEST_POLYGON_WKT = "POLYGON((0 0, 50 0, 100 100, 0 100, 0 0))";
|
public final static String TEST_POLYGON_WKT = "POLYGON((0 0, 50 0, 100 100, 0 100, 0 0))";
|
||||||
public final static String TEST_POINT_WKT = "POINT(0 0)";
|
public final static String TEST_POINT_WKT = "POINT(0 0)";
|
||||||
|
@ -793,7 +793,7 @@ public abstract class AbstractExpectationsFactory {
|
||||||
try {
|
try {
|
||||||
cn = createConnection();
|
cn = createConnection();
|
||||||
preparedStatement = nativeSQLStatement.prepare( cn );
|
preparedStatement = nativeSQLStatement.prepare( cn );
|
||||||
LOGGER.info( "Native SQL is: " + preparedStatement.toString() );
|
LOG.info( "Native SQL is: " + preparedStatement.toString() );
|
||||||
ResultSet results = preparedStatement.executeQuery();
|
ResultSet results = preparedStatement.executeQuery();
|
||||||
while ( results.next() ) {
|
while ( results.next() ) {
|
||||||
int id = results.getInt( 1 );
|
int id = results.getInt( 1 );
|
||||||
|
|
|
@ -28,8 +28,8 @@ package org.hibernate.spatial.testing;
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import com.vividsolutions.jts.io.ParseException;
|
import com.vividsolutions.jts.io.ParseException;
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.slf4j.Logger;
|
import org.hibernate.spatial.Log;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.hibernate.spatial.LogFactory;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -46,7 +46,7 @@ import java.util.Properties;
|
||||||
public class DataSourceUtils {
|
public class DataSourceUtils {
|
||||||
|
|
||||||
|
|
||||||
private static Logger LOGGER = LoggerFactory.getLogger( DataSourceUtils.class );
|
private static Log LOG = LogFactory.make();
|
||||||
|
|
||||||
|
|
||||||
private final SQLExpressionTemplate sqlExpressionTemplate;
|
private final SQLExpressionTemplate sqlExpressionTemplate;
|
||||||
|
@ -180,7 +180,7 @@ public class DataSourceUtils {
|
||||||
PreparedStatement pmt = cn.prepareStatement( "delete from GEOMTEST" );
|
PreparedStatement pmt = cn.prepareStatement( "delete from GEOMTEST" );
|
||||||
if ( !pmt.execute() ) {
|
if ( !pmt.execute() ) {
|
||||||
int updateCount = pmt.getUpdateCount();
|
int updateCount = pmt.getUpdateCount();
|
||||||
LOGGER.info( "Removing " + updateCount + " rows." );
|
LOG.info( "Removing " + updateCount + " rows." );
|
||||||
}
|
}
|
||||||
cn.commit();
|
cn.commit();
|
||||||
pmt.close();
|
pmt.close();
|
||||||
|
@ -205,13 +205,13 @@ public class DataSourceUtils {
|
||||||
Statement stmt = cn.createStatement();
|
Statement stmt = cn.createStatement();
|
||||||
for ( TestDataElement testDataElement : testData ) {
|
for ( TestDataElement testDataElement : testData ) {
|
||||||
String sql = sqlExpressionTemplate.toInsertSql( testDataElement );
|
String sql = sqlExpressionTemplate.toInsertSql( testDataElement );
|
||||||
LOGGER.debug( "adding stmt: " + sql );
|
LOG.debug( "adding stmt: " + sql );
|
||||||
stmt.addBatch( sql );
|
stmt.addBatch( sql );
|
||||||
}
|
}
|
||||||
int[] insCounts = stmt.executeBatch();
|
int[] insCounts = stmt.executeBatch();
|
||||||
cn.commit();
|
cn.commit();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
LOGGER.info( "Loaded " + sum( insCounts ) + " rows." );
|
LOG.info( "Loaded " + sum( insCounts ) + " rows." );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
|
@ -277,7 +277,7 @@ public class DataSourceUtils {
|
||||||
cn = getDataSource().getConnection();
|
cn = getDataSource().getConnection();
|
||||||
cn.setAutoCommit( false );
|
cn.setAutoCommit( false );
|
||||||
PreparedStatement statement = cn.prepareStatement( sql );
|
PreparedStatement statement = cn.prepareStatement( sql );
|
||||||
LOGGER.info( "Executing statement: " + sql );
|
LOG.info( "Executing statement: " + sql );
|
||||||
statement.execute();
|
statement.execute();
|
||||||
cn.commit();
|
cn.commit();
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
|
@ -5,11 +5,11 @@ import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
import org.hibernate.spatial.SpatialDialect;
|
import org.hibernate.spatial.SpatialDialect;
|
||||||
import org.hibernate.spatial.SpatialFunction;
|
import org.hibernate.spatial.SpatialFunction;
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -130,7 +130,7 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
|
||||||
return dialect.supportsFiltering();
|
return dialect.supportsFiltering();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected Logger getLogger();
|
abstract protected Log getLogger();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the query results to a Map.
|
* Adds the query results to a Map.
|
||||||
|
|
|
@ -30,16 +30,17 @@ package org.hibernate.spatial.testing.dialects.sqlserver.convertors;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
import org.hibernate.spatial.Log;
|
||||||
|
import org.hibernate.spatial.LogFactory;
|
||||||
import org.hibernate.spatial.dialect.sqlserver.convertors.Decoders;
|
import org.hibernate.spatial.dialect.sqlserver.convertors.Decoders;
|
||||||
import org.hibernate.spatial.dialect.sqlserver.convertors.Encoders;
|
import org.hibernate.spatial.dialect.sqlserver.convertors.Encoders;
|
||||||
import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType;
|
import org.hibernate.spatial.dialect.sqlserver.convertors.OpenGisType;
|
||||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||||
|
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||||
import org.hibernate.spatial.testing.TestData;
|
import org.hibernate.spatial.testing.TestData;
|
||||||
|
import org.hibernate.spatial.testing.TestSupport;
|
||||||
import org.hibernate.spatial.testing.dialects.sqlserver.SQLServerExpressionTemplate;
|
import org.hibernate.spatial.testing.dialects.sqlserver.SQLServerExpressionTemplate;
|
||||||
import org.hibernate.spatial.testing.dialects.sqlserver.SQLServerTestSupport;
|
import org.hibernate.spatial.testing.dialects.sqlserver.SQLServerTestSupport;
|
||||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
|
||||||
import org.hibernate.spatial.testing.TestSupport;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -55,10 +56,12 @@ import static org.junit.Assert.assertTrue;
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractConvertorTest extends SpatialFunctionalTestCase {
|
public abstract class AbstractConvertorTest extends SpatialFunctionalTestCase {
|
||||||
|
|
||||||
private DataSourceUtils dataSourceUtils;
|
private final static Log LOG = LogFactory.make();
|
||||||
|
|
||||||
private final static TestSupport support = new SQLServerTestSupport();
|
private final static TestSupport support = new SQLServerTestSupport();
|
||||||
|
|
||||||
|
private DataSourceUtils dataSourceUtils;
|
||||||
|
|
||||||
Map<Integer, Geometry> decodedGeoms;
|
Map<Integer, Geometry> decodedGeoms;
|
||||||
Map<Integer, Object> rawResults;
|
Map<Integer, Object> rawResults;
|
||||||
Map<Integer, byte[]> encodedGeoms;
|
Map<Integer, byte[]> encodedGeoms;
|
||||||
|
@ -131,9 +134,8 @@ public abstract class AbstractConvertorTest extends SpatialFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO -- add logger.
|
|
||||||
@Override
|
@Override
|
||||||
protected Logger getLogger() {
|
protected Log getLogger() {
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
return LOG;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -82,7 +82,6 @@ public class MLineStringTest extends TestCase {
|
||||||
|
|
||||||
int l = (int) Math.round( Math.random() * 250.0 );
|
int l = (int) Math.round( Math.random() * 250.0 );
|
||||||
l = Math.max( 2, l );
|
l = Math.max( 2, l );
|
||||||
System.out.println( "Size of arbitraryline ==" + l );
|
|
||||||
mcoar = new MCoordinate[l];
|
mcoar = new MCoordinate[l];
|
||||||
for ( int i = 0; i < mcoar.length; i++ ) {
|
for ( int i = 0; i < mcoar.length; i++ ) {
|
||||||
double x = Math.random() * 100000.0;
|
double x = Math.random() * 100000.0;
|
||||||
|
|
|
@ -30,14 +30,6 @@ import com.vividsolutions.jts.geom.PrecisionModel;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.spatial.jts.mgeom.EventLocator;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MCoordinate;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MCoordinateSequenceFactory;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MGeometryException;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MGeometryFactory;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MLineString;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MultiMLineString;
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,6 @@ import com.vividsolutions.jts.geom.PrecisionModel;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MCoordinate;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MCoordinateSequenceFactory;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MGeometryException;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MGeometryFactory;
|
|
||||||
import org.hibernate.spatial.jts.mgeom.MLineString;
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static junit.framework.Assert.fail;
|
import static junit.framework.Assert.fail;
|
||||||
|
|
||||||
|
|
|
@ -24,31 +24,31 @@
|
||||||
|
|
||||||
# Default unit/integration test config.
|
# Default unit/integration test config.
|
||||||
|
|
||||||
#hibernate.dialect org.hibernate.dialect.H2Dialect
|
hibernate.dialect org.hibernate.dialect.H2Dialect
|
||||||
#hibernate.connection.driver_class org.h2.Driver
|
hibernate.connection.driver_class org.h2.Driver
|
||||||
#hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
|
hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
|
||||||
#hibernate.connection.username sa
|
hibernate.connection.username sa
|
||||||
#
|
|
||||||
#hibernate.connection.pool_size 5
|
hibernate.connection.pool_size 5
|
||||||
#
|
|
||||||
#hibernate.show_sql false
|
hibernate.show_sql false
|
||||||
#
|
|
||||||
#hibernate.max_fetch_depth 5
|
hibernate.max_fetch_depth 5
|
||||||
#
|
|
||||||
#hibernate.cache.region_prefix hibernate.test
|
hibernate.cache.region_prefix hibernate.test
|
||||||
#hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||||
#
|
|
||||||
## NOTE: hibernate.jdbc.batch_versioned_data should be set to false when testing with Oracle
|
# NOTE: hibernate.jdbc.batch_versioned_data should be set to false when testing with Oracle
|
||||||
#hibernate.jdbc.batch_versioned_data true
|
hibernate.jdbc.batch_versioned_data true
|
||||||
|
|
||||||
|
|
||||||
## Configs for spatial databases (used during testing on local dev environment).
|
## Configs for spatial databases (used during testing on local dev environment).
|
||||||
|
|
||||||
hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisDialect
|
#hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisDialect
|
||||||
hibernate.connection.driver_class org.postgresql.Driver
|
#hibernate.connection.driver_class org.postgresql.Driver
|
||||||
hibernate.connection.url jdbc:postgresql://localhost:5432:hibbrtru
|
#hibernate.connection.url jdbc:postgresql://localhost:5432:hibbrtru
|
||||||
hibernate.connection.username hibbrtru
|
#hibernate.connection.username hibbrtru
|
||||||
hibernate.connection.password hibbrtru
|
#hibernate.connection.password hibbrtru
|
||||||
|
|
||||||
#hibernate.dialect org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
|
#hibernate.dialect org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
|
||||||
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
|
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
|
||||||
|
|
Loading…
Reference in New Issue