I have an entity
public class Arena {
@Id
private final Long id;
@Embedded(onEmpty = Embedded.OnEmpty.USE_NULL)
final Point location;
}
Point comes from org.springframework.data.geo package
and Postgres schema to it
CREATE TABLE arena
(
id SERIAL NOT NULL
CONSTRAINT arena_pk
PRIMARY KEY,
location POINT
);
when I'm trying to use the entity via spring data jdbc repository (arenaRepository.findAll())
public interface ArenaRepository extends CrudRepository<Arena, Long> {
}
I get an error
Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT arena.id AS id, arena.y AS y, arena.x AS x FROM arena]; nested exception is org.postgresql.util.PSQLException: ERROR: column arena.y does not exist
I see that SQL does not match schema. But is it possible to work with 'geo' classes via Spring Data Jdbc?
I tried introduce location as List and it works. Is it the right way?
You may annotate the field containing the org.springframework.data.geo.Point with @Embedded.
This will map it to two columns x and y.
I currently don't see a way to map it to a Postgres Point column.
There certainly isn't any special support for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With