隨筆 - 303  文章 - 883  trackbacks - 0
          <2007年11月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          歡迎光臨! 
          閑聊 QQ:1074961813

          隨筆分類(357)

          我管理的群

          公共blog

          • n維空間
          • Email : java3d@126.com 群 : 12999758

          參與管理的論壇

          好友的blog

          我的其他blog

          朋友的網站

          搜索

          •  

          最新評論

          spring整合hibernate時候往往出現sessionfatory報錯問題,請注意spring整合hibernate的時候最好不要配置HibernateSessionFactory

          下面的代碼使用了HibernateSessionFactory 原因是保留了hinetnate.cfg.xml 我認為也是一種解決辦法


          改代碼使用的數據庫為 oracle10g

           代碼比較長 貼出部分內容 其他的請自己下去看  點擊下載 hibernate_spring.zip

          package com.lusm.vo;

          /**
           * Hello generated by MyEclipse Persistence Tools
           
          */


          public class Hello implements java.io.Serializable {

              
          // Fields

              
          private HelloId id;

              
          // Constructors

              
          /** default constructor */
              
          public Hello() {
              }


              
          /** full constructor */
              
          public Hello(HelloId id) {
                  
          this.id = id;
              }


              
          // Property accessors

              
          public HelloId getId() {
                  
          return this.id;
              }


              
          public void setId(HelloId id) {
                  
          this.id = id;
              }


          }

          package com.lusm.vo;

          /**
           * HelloId generated by MyEclipse Persistence Tools
           
          */


          public class HelloId implements java.io.Serializable {

              
          // Fields

              
          private Long id;
              
          private String name;
              
          private String sex;

              
          // Constructors

              
          /** default constructor */
              
          public HelloId() {
              }


              
          /** full constructor */
              
          public HelloId(Long id, String name, String sex) {
                  
          this.id = id;
                  
          this.name = name;
                  
          this.sex = sex;
              }


              
          // Property accessors

              
          public Long getId() {
                  
          return this.id;
              }


              
          public void setId(Long id) {
                  
          this.id = id;
              }


              
          public String getName() {
                  
          return this.name;
              }


              
          public void setName(String name) {
                  
          this.name = name;
              }


              
          public String getSex() {
                  
          return this.sex;
              }


              
          public void setSex(String sex) {
                  
          this.sex = sex;
              }


              
          public boolean equals(Object other) {
                  
          if ((this == other))
                      
          return true;
                  
          if ((other == null))
                      
          return false;
                  
          if (!(other instanceof HelloId))
                      
          return false;
                  HelloId castOther 
          = (HelloId) other;

                  
          return ((this.getId() == castOther.getId()) || (this.getId() != null
                          
          && castOther.getId() != null && this.getId().equals(
                          castOther.getId())))
                          
          && ((this.getName() == castOther.getName()) || (this.getName() != null
                                  
          && castOther.getName() != null && this.getName()
                                  .equals(castOther.getName())))
                          
          && ((this.getSex() == castOther.getSex()) || (this.getSex() != null
                                  
          && castOther.getSex() != null && this.getSex().equals(
                                  castOther.getSex())));
              }


              
          public int hashCode() {
                  
          int result = 17;

                  result 
          = 37 * result + (getId() == null ? 0 : this.getId().hashCode());
                  result 
          = 37 * result
                          
          + (getName() == null ? 0 : this.getName().hashCode());
                  result 
          = 37 * result
                          
          + (getSex() == null ? 0 : this.getSex().hashCode());
                  
          return result;
              }


          }

          運行結果
          log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
          log4j:WARN Please initialize the log4j system properly.

          Hibernate: select hello0_.ID as ID2_, hello0_.NAME as NAME2_, hello0_.SEX as SEX2_ from LUSM.HELLO hello0_
          id    name    sex
          ---------------

          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男
          123    lusm    男

          如有錯誤或者疑問歡迎留言

          地震讓大伙知道:居安思危,才是生存之道。
          posted on 2007-11-08 11:48 小尋 閱讀(493) 評論(0)  編輯  收藏 所屬分類: j2se/j2ee/j2me
          主站蜘蛛池模板: 大安市| 阿瓦提县| 大连市| 大田县| 米易县| 石门县| 寻乌县| 盐津县| 耒阳市| 赫章县| 彭水| 凤台县| 重庆市| 林西县| 云和县| 翁源县| 绥芬河市| 万州区| 彭阳县| 大丰市| 岳池县| 金沙县| 特克斯县| 涿州市| 牙克石市| 阳城县| 京山县| 叶城县| 荣昌县| 凉城县| 巴中市| 鄂伦春自治旗| 陈巴尔虎旗| 平南县| 涟水县| 炎陵县| 蕲春县| 新蔡县| 昌吉市| 梧州市| 石柱|