Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value object as aggregate id without custom converter #1964

Closed
murilocardoso opened this issue Dec 29, 2024 · 1 comment
Closed

Value object as aggregate id without custom converter #1964

murilocardoso opened this issue Dec 29, 2024 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@murilocardoso
Copy link

murilocardoso commented Dec 29, 2024

In DDD, it's common to have a value object for the aggregate id, like this:

public class SomeAggregateId {
   @Column("id") 
   private final SomeType value;

   //.... constructors, getters, equals, toString, hashcode...
}

public class SomeAggregate {
   @Id
   private final SomeAggregateId  id

   //.... constructors, getters, equals, toString, hashcode, other methods...
}

I tried with embedded annotation too.

Unfortunately I could only make it work writing custom converters (JdbcCustomConversions) otherwise it tries to insert a null value into the id column in the database.

Therefore, to reduce the boilerplate code for converters, it would be great if Spring could handle this scenario natively, without requiring custom converters.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 29, 2024
@schauder schauder added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 2, 2025
@schauder
Copy link
Contributor

schauder commented Jan 2, 2025

With #1957 this will be possibly by marking SomeAggregate.id with @Embedded.

@schauder schauder closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants