Skip to content

Add support for compound keys defined using @IdClass #141

@bfg

Description

@bfg

Hi.

I have JPA entity which uses composite primary key:

@Entity
@IdClass(EntityId.class)
public class SomeEntity implements Serializable {
    @Id
    @Column(name = "message_id", updatable = false, nullable = false)
    @Type(type = "pg-uuid")
    private UUID firstId;

    @Id
    @Column(name = "recipient_id", updatable = false, nullable = false)
    @Type(type = "pg-uuid")
    private UUID secondId;

Everything works as expected using spring-data repository backed by postgresql, but trying to create spring-data-mock thows an exception:

com.mmnaseri.utils.spring.data.error.MultipleIdPropertiesException: There are multiple properties in class SomeEntity that are annotated as the ID property
    at com.mmnaseri.utils.spring.data.domain.impl.id.AnnotatedFieldIdPropertyResolver$1.doWith(AnnotatedFieldIdPropertyResolver.java:37)

It would be absolutely awesome if this would be supported by spring-data-mock, because i don't need to bring up the whole spring context for testing.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions