I'm struggling to identify the right annotations to use to map a star schema with Spring Boot JPA.
Let's consider 3 tables:
DIM_One (1)--------(1..n) FACT (1..n) ------------ (1) DIM_Two
DIM_One and DIM_Two both have an id that is their primary key. FACT's primary key is the combination of (DIM_One_pk, DIM_Two_pk)
For now, the annotations in my DIM tables are similar to :
@Table(name="DIM_One")
@Entity
@Getter
@ToString
public class One {
@Id
@Column(name = "dim_one_id")
private UUID id;
//...
}
As for the FACT table, I have :
@Entity
@Table(name = "FACT")
@ToString
@Getter
public class Fact {
@EmbeddedId
private FactId id;
//...
}
with the corresponding FactId class :
@Embeddable
@Getter
@EqualsAndHashCode
public class FactId implements Serializable {
private One one;
private Two two;
}
I feel a bit lost with the right annotations I would need to use to make it correspond to the cardinality:
DIM_One (1)--------(1..n) FACT (1..n) ------------ (1) Dim_Two
Furthermore, should it actually be mapped as OneToMany or OneToOne ?