我写了一些方法来获取像素,但它不起作用.它给我运行时错误.
实际上我在单独的类中运行此方法并在我的Activity类中初始化
Board board = new Board(this);
board.execute(URL);
Run Code Online (Sandbox Code Playgroud)
此代码以异步方式运行.请帮我.
public float getpixels(int dp){
//Resources r = boardContext.getResources();
//float px = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpis, r.getDisplayMetrics());
final float scale = this.boardContext.getResources().getDisplayMetrics().density;
int px = (int) (dp * scale + 0.5f);
return px;
}
Run Code Online (Sandbox Code Playgroud) 使用mysql和springboot jpa,
我正在尝试使用 JPA 实现 in 子句。当参数列表传递给规范时,在编写手动查询时获得预期结果,如下所示。employeeId 是一个字符串列,既有大写字母,也有小写字母。尽管手动查询有效,但必须实施规范。
手动查询:
SELECT emp
FROM EmployeeEntitiy emp
WHERE LOWER(emp.employeeIdParam) IN(
SELECT LOWER(empRel.destinationssid)
FROM EmployeeRelationEntity empRel WHERE ((LOWER(empRel.employeeId)=:employeeIdParam
OR UPPER(empRel.employeeId)=:employeeIdParam)
OR empRel.employeeId=:employeeIdParam)
Run Code Online (Sandbox Code Playgroud)
我如何检查大写和小写的列数据,就像toPredicate重写方法中的手动查询一样。JPA规格:
private class ParentChildCISpecification implements Specification<EmployeeEntitiy> {
List<String> employeeIdParamsList = new ArrayList<String>();
public ParentChildCISpecification(List<String> employeeIdParamsList) {
this.employeeIdParamsList = employeeIdParamsList;
}
@Override
public Predicate toPredicate(Root<EmployeeEntitiy> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
return root.get("employeeId").in(employeeIdParamsList);
}
}
Run Code Online (Sandbox Code Playgroud)