GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

Support for foreign key/joins in Spring Data Cloud Spanner

Open
#737 10 comments 4 reactions 0 assignees View on GitHub
priority: p3 spanner type: enhancement
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Is your feature request related to a problem? Please describe.**
The [documentation](https://cloud.spring.io/spring-cloud-gcp/1.1.x/multi/multi__spring_data_cloud_spanner.html) for Spring Data for Cloud Spanner claims that foreign key constraints are not natively supported in cloud spanner. Yet according to [this documentation](https://cloud.google.com/spanner/docs/foreign-keys/overview#how-to-define-foreign-keys), they are supported. While it seems interleaving is the ideal solution for one-to-many relationships, foreign keys are necessary for many-to-many relationships and sometimes for one-to-one. However it seems to ORM mapping annotations for spanner only supports `@Interleaved`. What's the current suggested solution for mapping `@OneToOne` and `@ManyToMany` relationships?

**Describe the solution you'd like**
Adding `@OneToOne`, `@OneToMany`, `ManyToOne`, and `@ManyToMany` mapping annotations to the [com.google.cloud.spring.data.spanner.core.mapping](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-data-spanner/src/main/java/com/google/cloud/spring/data/spanner/core/mapping) package for cases where we want to use foreign keys rather than interleaving.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.