收集袋与注释 [英] Collection Bag wtih annotation

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

问题描述

我正在观看由 Burt Beckwith制作的精彩视频



http://www.infoq.com/presentations/GORM-Performance 他说:


在传统的Hibernate中,您可以将集合映射为Bag,

其中只是一个没有订单或唯一性保证的常规集合


如何映射此集合时没有订单或唯一性和注释?如果您使用 List 作为参考类型,但是 不要指定一个索引号列,你将有一个没有唯一性要求的无序集合。是的,这个列表是在java层次上的一个有序集合,但是在实体的副本中没有保证他们有相同的订单。

  @OneToMany 
私人列表< OtherEntity>其他实体;

就这样!


I'm watching a good video made by Burt Beckwith

http://www.infoq.com/presentations/GORM-Performance

he says:

"In traditional Hibernate you could map the collection as Bag,

which is just a regular Collection with no ordering or uniqueness guarantees"

How Can I map this collection with no ordering or uniqueness with annotation? Thanks.

解决方案

If you use a List as the reference type but do not specify an index number column, you will have an unordered collection with no uniqueness requirement. Yes the list is an ordered collection at the java level, but there is no guarantee across copies of the entity that they have the same order.

@OneToMany
private List<OtherEntity> otherEntities;

That's all!

这篇关于收集袋与注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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