I'm already set up with Wildfly 10, Hibernate Spatial 5.0.1 and PostGis. I can insert data into database sucessufully (checked over psql command line) but when I try to read from database, I get the following error:
Caused by: java.lang.IllegalStateException: Received object of type byte[]
Here's my entity:
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;
}
and my method:
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;
}
Remembering, I can correctly insert data into it, but I can't read. First I thought about some inconsistency on Hibernate Spatial's notations, some broken dependency on pom.xml
or something wrong on persistence.xml
but since I can write I don't think this is the case. Here on method find
he queries exactly as I did. What I'm doing wrong?