一对多计数 [英] One-To-Many Count

查看:105
本文介绍了一对多计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这是否可以用更少的开销解决: 给定一个简单的一对多关系Product-> Size(产品有一个尺寸).为了弄清楚将多少个产品分配给一个大小,我将使用Product- Bag更新大小的映射.但是,如果我只对计数感兴趣(不需要任何产品详细信息),那可以在没有加载所有产品对象的开销的情况下完成呢?

I wonder if this can be resolved with less overhead: Given a simple one-to-many relationship Product --> Size (Product has got one size). In order to figure out how many products are assigned to a size I would update the mapping of Size with a Product-Bag. But what if I am only interested in the count (no need for any product details), can this be done without the overhead of loading all the product-objects?

任何小费的小费 sl3dg3

Thx for any tipps sl3dg3

推荐答案

在hbm中使用属性lazy="extra"或在流畅的映射中使用ExtraLazyLoad()进行产品集合. 通过额外的延迟加载Products.Count可以转换为sql'select count'

Use attribute lazy="extra" in hbm or ExtraLazyLoad() in fluent mappings for Product collection. With extra lazy loading Products.Count translates into sql 'select count'

请参见相应问题

这篇关于一对多计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆