今天在页面用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版本下,只能查,不能增删改,不报任何错误。