0
剛開始使用postgis和hibernate statial,並且我開始提出一些查詢問題。hibernate spatial 5 - Postgis2.2:查詢問題
目標:從(它的)幾何類型對象
在我的數據庫獲取一個博物館,我得到這個欄:
name: geom
type: geometry(Point,4326))
that contains something like: 0101000020E6100000004C8E1516D(...)
for each museum
然後,我有一個博物館類:
@Column(name = "geom", columnDefinition = "geometry(Point,4326)")
private Geometry geometry;
這是我的查詢:
WKTReader fromText = new WKTReader();
try {
//LON and LAT are the museum's coordinates
Geometry geom = fromText.read("POINT("+lon+" "+lat+")");
Session hibernateSession = getCurrentSession();
Museum result = hibernateSession
.createQuery("from Museum where geometry = :geometry")
.setParameter("geometry", geom).uniqueResult();
return result;
} catch (ParseException e) {
(...)
}
但是,當我試着執行它時,我得到這個錯誤:
ERROR: operator is not unique: geometry = bytea
Indice : Could not choose a best candidate operator. You might need to add explicit type casts.
所以我在想,也許幾何從休眠和幾何從POSTGIS是不一樣的? 關於如何讓它工作的任何想法?
謝謝!