이미 Wildfly 10, Hibernate Spatial 5.0.1 및 PostGis로 설정되어 있습니다. 내가 sucessufully 데이터베이스에 데이터를 삽입 할 수 있습니다 (psql의 명령 라인을 통해 확인)하지만 데이터베이스에서 읽을 때, 나는 다음과 같은 오류가 발생합니다 :Hibernate Spatial을 사용하여 PostGis에서 데이터 가져 오기
import com.vividsolutions.jts.geom.Point;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Location {
/*Empty constructor used on Hibernate*/
public Location() {
}
public Location(String name, Point point) {
this.name = name;
this.location = point;
}
@Id
private String name;
@Column(nullable = false)
private Point location;
}
내 방법 : 여기
Caused by: java.lang.IllegalStateException: Received object of type byte[]
내 기업의 :
public Location findByName(final String name) {
Query query = entityManager.createQuery("select l from Location l where l.name=:name", Location.class);
query.setParameter("name", name);
List<Location> result = query.getResultList();
if (result != null && result.size() > 0)
return result.get(0);
return null;
}
데이터를 올바르게 삽입 할 수는 있지만 읽을 수는 없습니다. 처음에 나는 Hibernate Spatial의 표기법, 불완전한 의존성이 pom.xml
이거나 무언가가 persistence.xml
인 것에 대해 약간의 불일치를 생각했다. 그러나 나는 이것을 쓸 수 있다고 생각하지 않는다. Here은 find
이고 그는 정확히 내가 한 쿼리를 사용합니다. 내가 뭘 잘못하고있어?