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

      <small id='sAsnH'></small><noframes id='sAsnH'>

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

        <legend id='sAsnH'><style id='sAsnH'><dir id='sAsnH'><q id='sAsnH'></q></dir></style></legend>
      1. <tfoot id='sAsnH'></tfoot>

      2. 有人可以在休眠中向我解释@MapsId吗?

        时间:2023-07-26

          <small id='4XqZS'></small><noframes id='4XqZS'>

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

                  <tfoot id='4XqZS'></tfoot>
                    <tbody id='4XqZS'></tbody>
                • <legend id='4XqZS'><style id='4XqZS'><dir id='4XqZS'><q id='4XqZS'></q></dir></style></legend>

                  本文介绍了有人可以在休眠中向我解释@MapsId吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有人可以向我解释一下休眠中的 @MapsId 吗?我很难理解它.

                  Can someone please explain to me @MapsId in hibernate? I'm having a hard time understanding it.

                  如果可以用一个例子来解释它会很棒,它最适用于什么样的用例?

                  It would be great if one could explain it with an example and in what kind of use cases is it most applicable?

                  推荐答案

                  这里有一个很好的解释,来自 对象数据库.

                  Here is a nice explanation from Object DB.

                  指定为 EmbeddedId 主键、EmbeddedId 主键中的属性或父实体的简单主键提供映射的 ManyToOne 或 OneToOne 关系属性.value 元素指定关系属性对应的复合键中的属性.如果实体的主键与关系引用的实体的主键的Java类型相同,则不指定value属性.

                  Designates a ManyToOne or OneToOne relationship attribute that provides the mapping for an EmbeddedId primary key, an attribute within an EmbeddedId primary key, or a simple primary key of the parent entity. The value element specifies the attribute within a composite key to which the relationship attribute corresponds. If the entity's primary key is of the same Java type as the primary key of the entity referenced by the relationship, the value attribute is not specified.

                  // parent entity has simple primary key
                  
                  @Entity
                  public class Employee {
                     @Id long empId;
                     String name;
                     ...
                  } 
                  
                  // dependent entity uses EmbeddedId for composite key
                  
                  @Embeddable
                  public class DependentId {
                     String name;
                     long empid;   // corresponds to primary key type of Employee
                  }
                  
                  @Entity
                  public class Dependent {
                     @EmbeddedId DependentId id;
                      ...
                     @MapsId("empid")  //  maps the empid attribute of embedded id
                     @ManyToOne Employee emp;
                  }
                  

                  阅读 API 文档 这里.

                  这篇关于有人可以在休眠中向我解释@MapsId吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:@Transactional(传播=传播.需要) 下一篇:如何使用@ComponentScan 注解扫描多个路径?

                  相关文章

                  最新文章

                    <bdo id='XuoS6'></bdo><ul id='XuoS6'></ul>
                • <legend id='XuoS6'><style id='XuoS6'><dir id='XuoS6'><q id='XuoS6'></q></dir></style></legend>

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

                      <small id='XuoS6'></small><noframes id='XuoS6'>