To store longitude and latitude as geometry location as Point in Postgres using spring boot jpa.
After applying below code it throws: column "location" is of type point but expression is of type bytea.
Also when fetching data it throws: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize
Add dependency in pom.xml
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>5.4.1.Final</version>
</dependency>
Add column in entity class.
@Column(columnDefinition = "POINT")
private Point location;
For storing data into database
GeometryFactory geometryFactory = new GeometryFactory();
Coordinate coordinate = new Coordinate();
coordinate.x = 2;
coordinate.y = 5;
Point myPoint = geometryFactory.createPoint(coordinate);
user.setLocation(myPoint);
I need to store data as (30.5,53.123) format in Postgres.