在此ManagedType上找不到具有给定名称[XXX]的属性

时间:2019-09-02 07:37:49

标签: jpa spring-data-jpa

原因:java.lang.IllegalArgumentException:无法为方法public abstract net.sdake.res1.entities.test.TestEntity net.sdake.res1.dao.TestDao.findByShopId(java.lang.Long)创建查询!在此ManagedType [net.sdake.res1.entities.test.TestEntity]上找不到具有给定名称[shopId]的属性

public class BaseEntity implements Serializable {

    @Column(name = "shop_id")
    protected Long shopId;

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }
}

@Entity
public class TestEntity extends BaseEntity {

    @GeneratedValue
    @Id
    private Long id;

    private Long name;

    public Long getId() {
        return id;
    }

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

    public Long getName() {
        return name;
    }

    public void setName(Long name) {
        this.name = name;
    }

    @Column(name = "shop_id")
    @Override
    public Long getShopId() {
        return shopId;
    }

    @Override
    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }
}

public interface TestDao extends JpaRepository<TestEntity,Long>{

    TestEntity findByShopId(Long shopId);

}

原因:java.lang.IllegalArgumentException:无法为方法public abstract net.sdake.res1.entities.test.TestEntity net.sdake.res1.dao.TestDao.findByShopId(java.lang.Long)创建查询!在此ManagedType [net.sdake.res1.entities.test.TestEntity]上找不到具有给定名称[shopId]的属性

启动错误报告

0 个答案:

没有答案