久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

      <tfoot id='FYXNL'></tfoot>
      <legend id='FYXNL'><style id='FYXNL'><dir id='FYXNL'><q id='FYXNL'></q></dir></style></legend>
        <bdo id='FYXNL'></bdo><ul id='FYXNL'></ul>

        Hibernate:通過注釋具有動態表名的數據對象

        Hibernate: Data Object with a dynamic table name by Annotations(Hibernate:通過注釋具有動態表名的數據對象)
        <tfoot id='r6VY5'></tfoot>

          1. <i id='r6VY5'><tr id='r6VY5'><dt id='r6VY5'><q id='r6VY5'><span id='r6VY5'><b id='r6VY5'><form id='r6VY5'><ins id='r6VY5'></ins><ul id='r6VY5'></ul><sub id='r6VY5'></sub></form><legend id='r6VY5'></legend><bdo id='r6VY5'><pre id='r6VY5'><center id='r6VY5'></center></pre></bdo></b><th id='r6VY5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='r6VY5'><tfoot id='r6VY5'></tfoot><dl id='r6VY5'><fieldset id='r6VY5'></fieldset></dl></div>
                <tbody id='r6VY5'></tbody>
              <legend id='r6VY5'><style id='r6VY5'><dir id='r6VY5'><q id='r6VY5'></q></dir></style></legend>

            1. <small id='r6VY5'></small><noframes id='r6VY5'>

                  <bdo id='r6VY5'></bdo><ul id='r6VY5'></ul>
                  本文介紹了Hibernate:通過注釋具有動態表名的數據對象的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個與表關聯的 Hibernate 數據類;想象像這樣的實體Person:

                  I have a Data Class for Hibernate associated to a table; imagine the Entity Person like this:

                   @Entity
                   @org.hibernate.annotations.Proxy(lazy=false)
                   @Table(name="Person", schema="MySchema")
                   @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
                   public class ProfileData implements Serializable {
                  
                      private static final long serialVersionUID = -844564646821609090L;
                  
                      public PersonData() {
                      }
                  
                      @Column(name="idPerson", nullable=false, unique=true)   
                      @Id 
                      ...
                  

                  我需要按此表的年份創建歷史表:Person2010、Person2011、Person2012... 是否可以不創建新的數據對象?也許通過參數...?我不知道.

                  I need to create historic tables by years of this table: Person2010, Person2011, Person2012... Is it possible without creating new Data Objects? Maybe by a parameter...? I don′t know.

                  Entity類是一樣的,表名和構造函數都變了.

                  The Entity class is the same, changing the table name and the constructor.

                  推薦答案

                  另一種架構,更復雜但優雅:

                  Another one Architecture, more complez but elegant:

                  YES,您可以使用 NamingStrategies 更改表名:

                  YES, You can change the table names using NamingStrategies:

                  public class MyNamingStrategy extends DefaultNamingStrategy {
                     ...
                     @Override
                     public  String tableName(String tableName) {
                        return tableName+yearSuffixTable;
                     }
                     ...
                  }
                  

                  而且,當您想使用 _year 表時,您必須使用 Hibernate 創建一個覆蓋 rhe 表名稱的會話:

                  And, when you wanna to use the _year tables, you must to create a session with Hibernate that override rhe table names:

                    SessionFactory sessionFactory;
                    Configuration config = new AnnotationConfiguration()
                                           .configure("hibernate.cfg.xml")
                                           .setNamingStrategy( new MyNamingStrategy () );
                    sessionFactory = config.buildSessionFactory();
                    session = sessionFactory.openSession();
                  

                  對于我的架構,我按年創建一個會話并將其存儲到應用程序映射中,以便在需要時訪問.

                  For my architecture I create a session by year and store it into Application map for access when I need it.

                  謝謝.

                  這篇關于Hibernate:通過注釋具有動態表名的數據對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)

                      <tbody id='T1ASs'></tbody>
                  • <small id='T1ASs'></small><noframes id='T1ASs'>

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

                      <tfoot id='T1ASs'></tfoot>

                        <legend id='T1ASs'><style id='T1ASs'><dir id='T1ASs'><q id='T1ASs'></q></dir></style></legend>
                          • <bdo id='T1ASs'></bdo><ul id='T1ASs'></ul>
                          • 主站蜘蛛池模板: 国产美女h视频 | 91网站在线看 | 国产男女猛烈无遮掩视频免费网站 | 亚洲一区二区在线播放 | 91精品亚洲 | 天天精品在线 | 三区在线 | 国产美女福利在线观看 | 成年男女免费视频网站 | www.毛片 | 草b视频 | 女人牲交视频一级毛片 | 99精品久久久久 | 日韩精品无码一区二区三区 | 91久久| 亚洲www| 97超碰免费| 国产精品美女久久久免费 | 一级毛片在线播放 | 日韩中文字幕在线 | 日韩欧美在线视频 | 黄色一级在线播放 | 国产日韩久久 | 91偷拍精品一区二区三区 | 99精品视频在线 | 欧美一区2区三区4区公司二百 | 国产不卡在线观看 | 一区二区三区视频播放 | 在线免费观看毛片 | 欧美一区二区三区在线播放 | 一区二区在线不卡 | 成人欧美 | 亚洲精品美女在线观看 | 日韩欧美在线观看 | 国产日韩亚洲欧美 | 午夜成人在线视频 | 久久精品久久精品久久精品 | 免费激情| 国产精品成人国产乱一区 | 另类一区 | 国产a区 |