获取属性中列表的大小
我有一个 A 类,其中有 B 元素列表。
在我的 A 类中,我想添加:
int size;
它将根据 B 元素的数量进行评估。因此,当我调用 myA.getSize()
时,我就会得到它。
是否可以在休眠映射中使用单个属性来映射计数查询?
我不想加载列表,这就是我想添加尺寸属性的原因。
I have a class A which have a list of B elements.
In my A class i would like to add:
int size;
which will be valued with the number of B elements. So when I would call myA.getSize()
I will have it.
Is it possible to map a count query with a single property in the hibernate mapping?
I don't want to load the list that is why i would like to add a size property.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,使用公式:
更多示例参见 示例:各种映射< /a>.
Yes, use a formula:
More examples in Example: Various Mappings.
另一种方法是在集合上使用lazy=extra。 参考文档中几乎没有提到这一点 并在此处进一步解释。
Another approach is to use lazy=extra on the collection. This is barely mentioned in the reference documentation and explained further here.