4

I have a simple project with the classes below defined. It works just fine in spring-boot 1.5.4, spring-data-commons 1.13, and spring-data-jpa 1.11.

When I upgrade to spring-boot 2.0.0.M5, spring-data-commons 2.0.0 and spring-data-jpa-2.0.0, I get a PropertyReferenceException at startup that says "No property delete found for type SimpleEntity!" Unfortunately, I can't get the stack trace out of the computer I get the error in, it is very locked down for security.

Any ideas? Other posts I found don't seem to match my situation.

Here are the classes (altered the names, but you get the idea):

package entity;

@MappedSuperclass
public abstract class BaseEntity implements Serializable {
....
}

package entity;

@Entity
@Table(schema = "ENTITIES", name = "SIMPLE")
public class SimpleEntity extends BaseEntity {
    @Column(name = "ID")
    private Long id;

    @Column(name = "CODE")
    private String code;

    @Column(name = "NAME")
    private String name;

    ... getters and setters ...
}

package repository;
imoport org.springframework.data.repository.Repository

public interface SimpleRepository extends Repository<SimpleEntity, Long> {
  public SimpleEntity save(SimpleEntity entity);
  public List<SimpleEntity> save(List<SimpleEntity> entities);
  public void delete(Long id);
  public SimpleEntity findOne(Long id);
  public List<SimpleEntity> findAllByOrderByNameAsc();
  public List<SimpleEntity> findByCode(String code);
  public List<SimpleEntity> findByNameIgnoreCaseOrderByNameAsc(String name);
}

1 Answer 1

5

Turns out there is a breaking change in Spring Data 2.0 CrudRepository interface. The error I received occurs under the following conditions:

  1. You have a 1.x Sping Data project
  2. You have an interface that extends Repository directly, not a subinterface like CrudRepository
  3. Your Repository subinterface declares the "void delete(ID)" method found in CrudRepository (in my case "void delete(Long)"
  4. You update to Spring Data 2.x

The problem is that CrudRepository in 2.x no longer has a "void delete(ID)" method, it was removed, and a new method "void deleteById(ID)" was added.

When Spring data sees a delete method signature it doesn't recognize, it produces an error about your entity class missing a delete property - this is true of both 1.2 and 2.x.

2
  • I have faced the same issue and haven't found any documentation for this case.
    – nivash
    Jan 16, 2018 at 10:20
  • I wouldn't expect there to be any docs for this. See point 2 above: I was choosing to use Repository - an empty interface - where it us up to me to correctly define methods that are some subset of CrudRepository. If I go this route and declare a method with an unrecognized signature, that's my problem :) It just means I have to be aware of this when upgrading. The only thing Spring could do better is to provide an error message that just says an unrecognized method signature is declared, with a URL to the JavaDocs for the Repository interface of that specific version of Spring Data.
    – Greg
    Jan 19, 2018 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.