How to create composite keys in entity class for spring data neo4j

Viewed 18

When I am trying to create composite keys with two @id I am getting the following error. org.springframework.data.mapping.MappingException: Attempt to add id property private java.lang.String ANumber but already have property private java.lang.String BNumber registered as id. Check your mapping configuration!

How can I define composite keys in entity class for spring data neo4j ?

I was trying to do the same as here (https://www.baeldung.com/jpa-composite-primary-keys)

Customer.java

​
@Node("customer")
public class Customer{
​
    public CustomerId getCustomerId() {
        return customerId;
    }
​
    public void setCustomerId(CustomerId customerId) {
        this.customerId= customerId;
    }
​
    @EmbeddedId
    private CustomerId customerId ;

CustomerId.java


@Embeddable
public class CustomerId implements Serializable {
​
​
    private String ANumber;
​
    private String BNumber;
​
    public CustomerId() {
​
    }
    public CustomerId(String ANumber, String BNumber) {
        this.ANumber= ANumber;
        this.BNumber= BNumber;
    }
​```
0 Answers
Related