//调用
public List<SdoMode> getGeoData(){
Sql sql = Sqls.create("select * from test_h2");
Entity<SdoMode> entity = dao().getEntity(SdoMode.class);
sql.setEntity(entity);
sql.setCallback(Sqls.callback.entities());
dao().execute(sql); //出错处
List<SdoMode> list = sql.getList(SdoMode.class);
return list;
}
//报错
08-Oct-2018 16:35:01.004 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\apache-tomcat-8.0.44\webapps\manager has finished in 994 ms
[WARN ] 2018-10-08 16:35:02,034 org.nutz.dao.impl.entity.AnnotationEntityMaker.make(AnnotationEntityMaker.java:117) - No @Table found, fallback to use table name='sdo_mode' for type 'cn.wizzer.app.cms.modules.models.SdoMode'
[DEBUG] 2018-10-08 16:35:02,228 org.nutz.dao.jdbc.Jdbcs.guessEntityFieldColumnType(Jdbcs.java:881) - take field 'sdoData(oracle.spatial.geometry.JGeometry)'(cn.wizzer.app.cms.modules.models.SdoMode) as VARCHAR(128)
[DEBUG] 2018-10-08 16:35:03,595 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - select * from test_h2
org.nutz.dao.DaoException: java.lang.ClassCastException: com.vividsolutions.jts.geom.LineString cannot be cast to org.locationtech.jts.geom.Geometry
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:140)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:93)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:1013)
at cn.wizzer.app.templet.modules.service.impl.PopulationServiceImpl.getGeoData(PopulationServiceImpl.java:456)
at cn.wizzer.app.web.commons.core.Setup.initStatisticsData(Setup.java:1032)
at cn.wizzer.app.web.commons.core.Setup.init(Setup.java:79)
7 回复
@wendal
重写get方法
public Object get(ResultSet rs, String colName) throws SQLException {
//WKT w = new WKT();
//Geometry q =(Geometry) rs.getObject(colName);
String rspstr = ((Geometry) rs.getObject(colName)).toString();
JGeometry geo = null;
try {
geo = new WKT().toJGeometry(rspstr.getBytes());
} catch (GeometryExceptionWithContext geometryExceptionWithContext) {
geometryExceptionWithContext.printStackTrace();
}
return geo;
}
添加回复
请先登陆