I have two really simple JPA Spring Entities : Farm and Coordinates
@Entity
@Getter
@Setter
@Table(name = "farms")
public class FarmEntity {
@Id
Long id;
@Column(name = "categorie")
String categorie;
@Column(name = "nom")
String nom;
@Column(name = "description")
String description;
@OneToOne
@JoinColumn(name = "id")
Coordinates coordinate;
}
// COORDINATES.JAVA
@Entity
@Getter
@Setter
@Table(name = "coordinates")
public class Coordinates {
@Id
Long id;
@Column(name = "type")
String type;
@Column(name = "lat")
String lat;
@Column(name = "lon")
String lon;
}
I have about 16k rows in my postgre database,
When im fetching data from JPA Repository -> 200OK 8.34 s 6.56 MB
When im doing a simple JOIN TABLE in sql
SELECT *
FROM farms f
INNER JOIN coordinates c ON f.id = c.id;
-
16509 row(s) feteched in 0.037s (0.012s fetch)
Why is there this HUUUGE difference between OneToOne and my JOIN table in SQL ?
Maybe there is a better way to implement this in my entities but i dont find anything even in spring documentations
Thanks for any help or explainations 🙂
François Lesur is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.