Java 无参数的Hibernate接口

Java 无参数的Hibernate接口,java,spring-data-jpa,Java,Spring Data Jpa,我想用cntStock查找所有StockAtLocations!=oldStock,我可以用@Query注释编写它,但这对我来说似乎是错误的,但我不知道如何在我的界面中编写它 @Entity @Getter @Setter public class StockAtLocation implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(nullable = false, uniq

我想用cntStock查找所有StockAtLocations!=oldStock,我可以用@Query注释编写它,但这对我来说似乎是错误的,但我不知道如何在我的界面中编写它

@Entity
@Getter
@Setter
public class StockAtLocation implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(nullable = false, unique = true)
private Long id;

private String oldStockArea;
private String note;
private int oldStock;
private int cntStock;

@JoinColumn(nullable = false)
@ManyToOne(optional = false, cascade = CascadeType.PERSIST)
private StorageLocation storageLocation;

@ManyToOne
private Article article;

}
这就是我试过的

interface StockAtLocationRepository extends CrudRepository<StockAtLocation, Long> {
    public List<StockAtLocation> findByNoteNotNull();

    // this does not work.
    public List<StockAtLocation> findByNotOldstockEqualCntstock();
}
接口StockAtLocationRepository扩展了Crudepository{
公共列表findByNoteNotNull();
//这是行不通的。
公共列表findByNotOldstockEqualCntstock();
}
这是编译器输出

org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“deviceService”的bean时出错:通过字段“stockRepo”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“stockAtLocationService”的bean时出错:通过字段“stockRepo”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“stockAtLocationRepository”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:未能创建查询方法public abstract java.util.List com.mm.inventur.services.StockAtLocationRepository.findByNotOldstockEqualCntstock()!找不到StockAtLocation类型的属性NOTLDSTOCKEQUALCNTSTOCK! 在org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement.inject(AutoWiredNotationBeanPostProcessor.java:588)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.annotation.AutowiredNotationBeanPostProcessor.postProcessPropertyValues(AutowiredNotationBeanPostProcessor.java:366)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:761)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE] 在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 位于org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:303)[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 在com.mm.inventur.InventurApplication.main(InventurApplication.java:12)[classes/:na] 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)~[na:1.8.0_161] 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)~[na:1.8.0_161] 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:1.8.0¡] 在java.lang.reflect.Method.invoke(Method.java:498)~[na:1.8.0_161] 在org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)[spring-boot-devtools-1.5.9.RELEASE.jar:1.5.9.RELEASE] 原因:org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“stockAtLocationService”的bean时出错:通过字段“stockRepo”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“stockAtLocationRepository”的bean时出错:调用init方法失败;嵌套异常为java.lang.IllegalArgumentException:未能创建查询方法public abstract java.util.List com.mm.inventur.services.StockAtLocationRepository.findByNotOldstockEqualCntstock()!找不到StockAtLocation类型的属性NOTLDSTOCKEQUALCNTSTOCK! 在org.springframework.beans.factory.annotation.AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement.inject(AutoWiredNotationBeanPostProcessor.java:588)~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELE