mysql - MySQL - TypedQuery 忽略构造函数的空值
问题描述
对于 TypedQuery:
TypedQuery<MyObject> query = em.createQuery(
"SELECT new " + MyObject.class.getName() + "(o.id, o.value1, o.value2, o.value3, z, t.id, possiblyNull, o.either, o.or) FROM Table1 AS t " +
"JOIN t.objects AS o JOIN o.zValue AS z JOIN o.child AS b JOIN b.parent AS possiblyNull " +
"WHERE t.id IN(:table1Ids)", MyObject.class);
query.setParameter("table1Ids", table1Ids);
return query.resultsList();
resultsList
始终为空。对于某些值,该属性possiblyNull
可能为空。属性o.either
和o.or
是OneToMany
与表 1 的(OneToMany
相关)对象的关系。
如果我尝试一次获取每个值(fe 表示 TypedQueryo.either
而不是完整的构造函数,我会得到所有不是的o.either
结果null
)它可以工作。有没有办法为每个获取所有构造函数条目o.id
,而不管某些其他属性是否存在null
?
解决方案
推荐阅读
- asp.net - WPF ManagementScope 访问被拒绝
- django - Django 多条删除记录
- android - 我在使用带有 CameraX 的 PreviewView 时遇到了问题?
- python - 有没有办法在 AWS Lambda 上使用 PyGithub
- node.js - 为 https 配置 nginx (docker) 后应用程序停止
- python - 训练精度高,验证精度低 CNN 二元分类 keras
- c++ - 类模板 - 如何编写构造函数
- typescript - 使用 express.Route() 部署 Firebase Cloud 函数时出错
- swift - 为什么在 swift 的 mac 命令行工具中使用 DispatchQueue.main.async 时需要运行循环?
- c# - 使用openxml的ppt中的段落没有更改为所需的格式