简体   繁体   English

使用休眠条件从对象获取字符串(集合)列表

[英]Getting list of string(Collection) from an object using hibernate criteria

I have a class as following 我有一个以下课程

Class Department {
    private String departmentName;
    private List<String> students;
    ....
    ....
    ....
}   

Now i want to fetch students attribute ( List<String> ) only from Department class but not entire Department object with restriction departName := Chemistry. 现在我只想从部门类中获取学生属性( List<String> ),而不是整个部门对象(具有限制departName:= Chemistry)。

How to write hibernate criteria for this??? 如何为此编写休眠标准???

About you question: no, this projection is not possible because collection of elements has the same lifecycle of owner entity 关于您的问题:不可以,因为元素集合具有与所有者实体相同的生命周期,所以无法进行此投影
Getting collections of elements with criteria is not possibile (read here ). 用条件获取元素的集合是不可能的( 在此处阅读)。 You have to work with native SQL to return List<String> . 您必须使用本机SQL返回List<String>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM