2
public interface MyRespository extends CrudRepository<MyEntity, Long> {
    @CachePut(value = "mycache", key = "id")
    @Override
    public <S extends MyEntity> S save(S entity);
}

@Entity
public class MyEntity {
    @Id
    private Long id;

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
}

Result:

org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'id' cannot be found on object of type 'org.springframework.cache.interceptor.CacheExpressionRootObject' - maybe not public?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

1

Accessing the object by index with key = "#a0.id" worked, but I still don't know why it's not possible to access the object by its name.

membersound
  • 81,582
  • 193
  • 585
  • 1,120