Entity Id of TimescaleDB + JPA

18 views Asked by At

I'm creating Spring Boot application with TimescaleDB. On each timestamp there are object's name(foo, bar, baz, ...), value, etc. I've heard that TimescaleDB uses timestamp as primary key. But @Id on timestamp column returns duplicate values on same timestamp.

Entity.java

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Entity {
  @Id
  private Timestamp time;

  private Integer value;

  private String name;
}

EntityRepository.java

public interface EntityRepository extends JpaRepository<Entity, Timestamp> {
  List<Entity> findByTime(Timestamp time);
}

result of findByTime

[{"time": 2024-02-26T00:00:00.000, "value": 123, "name": "foo"},
{"time": 2024-02-26T00:00:00.000, "value": 123, "name": "foo"},
{"time": 2024-02-26T00:00:00.000, "value": 123, "name": "foo"},
...
{"time": 2024-02-26T00:00:00.000, "value": 123, "name": "foo"}]
0

There are 0 answers