Skip to content

Access to identifier property not guarded properly #711

@MugenTwo

Description

@MugenTwo

Hi!

As mentioned in the title, Persistable does not seem to be working correctly with R2DBC.
This interface has 2 methods: getId() and isNew(). The latter seems to be working fine.

But I don't think getId() is working fine as I am get the following error whenever I use the save() method of the ReactiveCrudRepository:

at org.springframework.data.mapping.PersistentEntity.getRequiredIdProperty(PersistentEntity.java:106)

My entity is as follows:

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.Persistable;

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Foo implements Persistable<String> {

    String x;
    String y;
    String z;

    @Transient
    private boolean isNew;

    @Id
    @Transient
    @Override
    public String getId() {
        return x + "-" + y;
    }

    @Override
    public boolean isNew() {
        return isNew;
    }

}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions