問題集錦
今天在頁面用logic:present去顯示時(shí),并沒有用到任何bean:message卻報(bào)個(gè):
hibernate版本問題:
做一個(gè)hibernate簡單測試,代碼如下
Test2.hhm.xml
發(fā)現(xiàn):在3.1版本下能正常運(yùn)行,但在3.0版本下,只能查,不能增刪改,不報(bào)任何錯(cuò)誤。
Cannot find message resources under key org.apache.struts.action.MESSAGE
錯(cuò)誤,在struts-config.xml配個(gè)默認(rèn)的資源文件文件就可以了!奇怪hibernate版本問題:
做一個(gè)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<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>
<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>
測試代碼:<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自動生成的那個(gè)HibernateSessionFactory.java.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();
發(fā)現(xiàn):在3.1版本下能正常運(yùn)行,但在3.0版本下,只能查,不能增刪改,不報(bào)任何錯(cuò)誤。
posted on 2007-09-15 23:01 月芽兒 閱讀(208) 評論(0) 編輯 收藏 所屬分類: J2EE學(xué)習(xí)心得