我试图用Spring数据JPA实现以下查询,方法名称解析.
select count(*) from example ex where ex.id = id and ex.status in (1, 2);
Run Code Online (Sandbox Code Playgroud)
我知道crud repo中有一个方法可以计算 - countByIdAndStatus(params)但我不知道如何将"in"子句与此方法结合起来.
谢谢!
我正在尝试对调用 ngOnInit 中的服务方法的组件进行单元测试。当我尝试运行测试时,出现错误:
类型错误: this.adminService.getTestString(...).subscribe 不是函数
以下是供参考的文件。
应用程序组件.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'ISAppAdmin';
greet: String;
errorMessage: String;
constructor(private adminService: AdminService, private router: Router) {}
ngOnInit() {
this.adminService.getTestString().subscribe(
data => this.greet = data,
error => this.errorMessage = < any > error
)
this.adminService.putTestString().subscribe(
res => console.log(res),
error => this.errorMessage = < any > error
)
console.log("in app");
}
onClick() {
console.log("button clicked");
this.router.navigate(['admin']);
console.log("still on same page");
}
}Run Code Online (Sandbox Code Playgroud)
应用程序.组件.规格.ts