<tfoot id='DFSjE'></tfoot>

  • <i id='DFSjE'><tr id='DFSjE'><dt id='DFSjE'><q id='DFSjE'><span id='DFSjE'><b id='DFSjE'><form id='DFSjE'><ins id='DFSjE'></ins><ul id='DFSjE'></ul><sub id='DFSjE'></sub></form><legend id='DFSjE'></legend><bdo id='DFSjE'><pre id='DFSjE'><center id='DFSjE'></center></pre></bdo></b><th id='DFSjE'></th></span></q></dt></tr></i><div id='DFSjE'><tfoot id='DFSjE'></tfoot><dl id='DFSjE'><fieldset id='DFSjE'></fieldset></dl></div>
    1. <small id='DFSjE'></small><noframes id='DFSjE'>

    2. <legend id='DFSjE'><style id='DFSjE'><dir id='DFSjE'><q id='DFSjE'></q></dir></style></legend>

          <bdo id='DFSjE'></bdo><ul id='DFSjE'></ul>

        多对多关系的属性(休眠)

        时间:2023-09-27
      1. <legend id='2C95X'><style id='2C95X'><dir id='2C95X'><q id='2C95X'></q></dir></style></legend>

      2. <small id='2C95X'></small><noframes id='2C95X'>

              <tfoot id='2C95X'></tfoot>
                <bdo id='2C95X'></bdo><ul id='2C95X'></ul>
                <i id='2C95X'><tr id='2C95X'><dt id='2C95X'><q id='2C95X'><span id='2C95X'><b id='2C95X'><form id='2C95X'><ins id='2C95X'></ins><ul id='2C95X'></ul><sub id='2C95X'></sub></form><legend id='2C95X'></legend><bdo id='2C95X'><pre id='2C95X'><center id='2C95X'></center></pre></bdo></b><th id='2C95X'></th></span></q></dt></tr></i><div id='2C95X'><tfoot id='2C95X'></tfoot><dl id='2C95X'><fieldset id='2C95X'></fieldset></dl></div>
                    <tbody id='2C95X'></tbody>

                  本文介绍了多对多关系的属性(休眠)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有实体类 A 和 C.它们映射表 tblA 和 tblC 并且它们之间具有多对多关系,而 tblB 在它们之间进行映射.tblB 包含 A_ID、C_ID 和 SetDate,最后一个是设置的日期,因此是关系的一个属性.我的问题是,我如何最好地映射这个属性?目前它们未映射,如下所示:

                  I have entity classes A and C. They are mapping the tables tblA and tblC and have a many-to-many relationship between them, with tblB to map between them. tblB contains A_ID, C_ID and SetDate, the last one being the date it was set, thus an attribute to the relationship. My question is, how do I best map in this attribute? At the moment they're unmapped, like this:

                  答:

                  @ManyToMany(targetEntity=C.class, cascade={ CascadeType.PERSIST, CascadeType.MERGE } )
                  @JoinTable(name="tblB", joinColumns=@JoinColumn(name="A_ID"), inverseJoinColumns=@JoinColumn(name="C_ID") )
                  private Collection<C> Cs;
                  

                  C:

                  @ManyToMany( cascade = {CascadeType.PERSIST, CascadeType.MERGE}, mappedBy = "Cs", targetEntity = A.class )
                  private Collection<A> As;
                  

                  我应该如何从中获得 tblB.SetDate?

                  How should I get tblB.SetDate out of this?

                  干杯

                  尼克

                  推荐答案

                  据我所知,不可能这样映射,你必须切换到 One-To- 多对一关系,中间是你的 B.您的日期将是 B 的一个属性.

                  From what I know, it is not possible to map it this way, you have to switch to One-To-Many and a Many-To-One relationships, with your B in the middle. Your date will be an attribute of B.

                  由于缺乏进化性,Hibernate 文档建议一般避免多对多,并从一开始就使用这两种关系.

                  For this lack of evolutivity, the Hibernate documentation recommends to avoid the Many-To-Many in general, and use the two relationships from the beginning.

                  这篇关于多对多关系的属性(休眠)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Eclipse 自动完成快捷方式不显示使用复合组件的新 下一篇:JSF 自定义组件:支持自定义类型的参数,从不调用

                  相关文章

                  最新文章

                    <i id='cAc0R'><tr id='cAc0R'><dt id='cAc0R'><q id='cAc0R'><span id='cAc0R'><b id='cAc0R'><form id='cAc0R'><ins id='cAc0R'></ins><ul id='cAc0R'></ul><sub id='cAc0R'></sub></form><legend id='cAc0R'></legend><bdo id='cAc0R'><pre id='cAc0R'><center id='cAc0R'></center></pre></bdo></b><th id='cAc0R'></th></span></q></dt></tr></i><div id='cAc0R'><tfoot id='cAc0R'></tfoot><dl id='cAc0R'><fieldset id='cAc0R'></fieldset></dl></div>

                      <bdo id='cAc0R'></bdo><ul id='cAc0R'></ul>
                    1. <small id='cAc0R'></small><noframes id='cAc0R'>

                      <legend id='cAc0R'><style id='cAc0R'><dir id='cAc0R'><q id='cAc0R'></q></dir></style></legend>

                      <tfoot id='cAc0R'></tfoot>