错误:
com.vertica.support.exceptions.DataException:[Vertica]VJDBC 错误:无法直接插入或复制用户定义的类型。请使用适当的用户定义函数计算它们
我现在的方言
public class VerticaDialect extends org.hibernate.spatial.dialect.postgis.PostgisDialect {
private static final String SELECT_LAST_INSERT_ID = "SELECT LAST_INSERT_ID()";
@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return new IdentityColumnSupport() {
...
@Override
public String getIdentitySelectString(String arg0, String arg1, int arg2) throws MappingException {
return SELECT_LAST_INSERT_ID;
}
...
};
}
}
我的依赖
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>5.1.1.Final</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>
我的 Vertica 表
alter table something add GIS_WGS84 GEOGRAPHY NULL;
我的模型
import org.geolatte.geom.C2D;
import org.geolatte.geom.G2D;
import org.geolatte.geom.Polygon;
@Column(name="gis_wgs84")
public Polygon<G2D> getGisWGS84() {
return gisWGS84;
}
public void setGisWGS84(Polygon<G2D> gisWGS84) {
this.gisWGS84 = gisWGS84;
}
我的测试
Geographic2DCoordinateReferenceSystem wgs84 = CrsRegistry.getGeographicCoordinateReferenceSystemForEPSG(4326); // G2D
PositionSequence<G2D> wgs84positionSequence =
PositionSequenceBuilders.fixedSized(5, G2D.class)
.add(new G2D(30.0, 60.0))
.add(new G2D(30.0, 61.0))
.add(new G2D(31.0, 61.0))
.add(new G2D(31.0, 60.0))
.add(new G2D(30.0, 60.0))
.toPositionSequence();
Polygon<G2D> wgs84poly = new Polygon<>(wgs84positionSequence, wgs84);
something.setGisWGS84(wgs84poly);
我的问题:
- 我应该使用
org.geolatte.geom.Polygon
还是其他?还有这个com.vividsolutions.jts.geom
包。我很困惑。Hibernate ORM文档没有用;它提到了两者,并且该示例未显示导入。 - 我应该覆盖 Postgis 方言吗?Vertica 使用函数加载数据
ST_GeographyFromText('LINESTRING(-42.0 23.0, -62.0 23.0)')