@OneToMany 和 @ElementCollection 的区别? [英] Difference between @OneToMany and @ElementCollection?

查看:20
本文介绍了@OneToMany 和 @ElementCollection 的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 @OneToMany@ElementCollection 注释有什么区别,因为两者都适用于一对多关系?

What is the difference between using a @OneToMany and @ElementCollection annotation since both work on the one-to-many relationship?

推荐答案

我相信 @ElementCollection 主要用于映射非实体(embeddable 或 basic)而 @OneToMany用于映射实体.因此,使用哪一个取决于您想要实现的目标.

I believe @ElementCollection is mainly for mapping non-entities (embeddable or basic) while @OneToMany is used to map entities. So which one to use depend on what you want to achieve.

这篇关于@OneToMany 和 @ElementCollection 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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