如何将 JPQL 查询分配给简单的 Java 对象?
我需要将 jpql 结果的结果分配给一个简单的类 java 对象
我有这样的东西
class myObject() {
@id
private Long id;
private String Name;
private String description;
...
//getters and setters
}
我需要以某种方式存储此 SQL 查询的结果,例如
// 可以是 anytable SELECT DISTINCT c.table_id, c.name, NULL AS description FROM anyTable
如何在 JPQL 中执行此操作,然后将结果分配给我的对象?
I need to assign the result of a jpql result to a simple class java object
I have something like this
class myObject() {
@id
private Long id;
private String Name;
private String description;
...
//getters and setters
}
I need to somehow to store the result of this SQL query, example
// could be anytable
SELECT DISTINCT c.table_id, c.name, NULL AS description FROM anyTable
How do I do this in JPQL and then assign the result to my object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题非常不清楚。所以这是一个模糊的答案:
The question is extremely unclear. So here is a vague answer:
我想,这就是答案!
它是Entity.PersonWell类的构造函数:
有一些用于提取结果的代码:
我希望,它会对您有所帮助! :)
I think, it's the answer!
And it's a constructor of entities.PersonWell class:
There's some code for an extraction of result:
I hope, It'll help you! :)