神秘的 J2ee 殿堂

          ·古之學者必有師·做學者亦要做師者·FIGHTING·

          問題集錦

          今天在頁面用logic:present去顯示時,并沒有用到任何bean:message卻報個:
          Cannot find message resources under key org.apache.struts.action.MESSAGE
          錯誤,在struts-config.xml配個默認的資源文件文件就可以了!奇怪

          hibernate版本問題:
          做一個hibernate簡單測試,代碼如下
          Test2.hhm.xml
              <class name="bean.Test2" table="Test2" schema="dbo" catalog="xiaoxiao">
                  
          <id name="id" type="java.lang.Integer">
                      
          <column name="ID" />
                      
          <generator class="increment" />
                  
          </id>
                  
          <property name="name" type="java.lang.String">
                      
          <column name="NAME" length="50" />
                  
          </property>
              
          </class>
          hibernate.cfg.xml
          <session-factory>
              
          <property name="connection.username">sa</property>
              
          <property name="connection.url">
                  jdbc:microsoft:sqlserver:
          //localhost:1433;DatabaseName=xiaoxiao
              </property>
              
          <property name="dialect">
                  org.hibernate.dialect.SQLServerDialect
              
          </property>
              
          <property name="myeclipse.connection.profile">sql2000</property>
              
          <property name="connection.password">sa</property>
              
          <property name="connection.driver_class">
                  com.microsoft.jdbc.sqlserver.SQLServerDriver
              
          </property>
              
          <property name="show_sql">true</property>
              
          <property name="current_session_context_class">thread</property>
              
          <mapping resource="bean/Test2.hbm.xml" />
          </session-factory>
          測試代碼:
                  Session session = HibernateSessionFactory.getSessionFactory()
                          .getCurrentSession();
                  session.beginTransaction();

          /*        List ha = new ArrayList();
                  // ha=session.createQuery("from Test").list();
                  ha = session.createCriteria(Test2.class).list();
                  for (Iterator it = ha.iterator(); it.hasNext();) {
                      Test2 test2 = (Test2) it.next();
                      System.out.println(test2.getName());
                  }
          */
          /*        Test2 test2=new Test2();
                  test2.setName("haha");
                  session.save(test2);
          */
                  
          /*        Test2 test2=(Test2)session.load(Test2.class, 3);
                  test2.setName("love you");
          */
                  
          /*        Test2 test2=(Test2)session.load(Test2.class, 3);
                  session.delete(test2);
          */
                  
                  session.beginTransaction().commit();
          其中HibernateSessionFactory類是用的myeclipse自動生成的那個HibernateSessionFactory.java
          發現:在3.1版本下能正常運行,但在3.0版本下,只能查,不能增刪改,不報任何錯誤。




          posted on 2007-09-15 23:01 月芽兒 閱讀(213) 評論(0)  編輯  收藏 所屬分類: J2EE學習心得

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 上虞市| 红安县| 宜川县| 淮安市| 恩平市| 株洲市| 海安县| 萨嘎县| 珲春市| 高邑县| 平潭县| 卢湾区| 哈密市| 桂东县| 合水县| 杭州市| 钦州市| 会东县| 天全县| 中西区| 平阴县| 平和县| 宜城市| 津市市| 锦屏县| 阳朔县| 阳泉市| 花莲市| 玉屏| 兴业县| 东宁县| 紫阳县| 璧山县| 崇明县| 西城区| 兴安县| 惠东县| 平陆县| 霍州市| 武川县| 崇文区|