spring-projects / spring-projects/spring-data-relational

Support `suffix` for `@Embedded`

Open
#2,303 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

Problem

Spring Data Relational's @Embedded currently only supports a prefix attribute to group multiple columns belonging to an embedded type (class/record). This works well where a common prefix is the natural grouping mechanism given by the language. However, there are some cases where a common suffix is the natural way to group these columns, and where suffix attribute on @Embedded would make the mapping more intuitive.

Examples

  • first_name, last_name
  • home_phone, work_phone, mobile_phone
  • min_age, max_age, median_age, avg_age

Use case could look like this:

record Statistics(int min, int max, int median, int average) {}

@Embedded(suffix = "_age") Statistics ageStatistics

There might even be use cases where both prefix and suffix together form the natural way of grouping things together in the english language. Couldn't come up of concrete examples there though.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the @Embedded mapping implementation and the existing handling for its prefix attribute. Trace how embedded column names are derived, then identify the tests covering prefix behavior. Done means suffix works for the Statistics example and the existing prefix behavior remains unchanged, with coverage for suffix and combined prefix/suffix cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.