Skip to content

Value object as aggregate id without custom converter #1964

Closed as not planned
@murilocardoso

Description

@murilocardoso

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions