S2SH 着手项目所遇到的问题

1、查看客户时发生的错误

严重: Exception occurred during processing request: customer_info is not mapped [from customer_info]; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: customer_info is not mapped [from customer_info]
org.springframework.orm.hibernate5.HibernateQueryException: customer_info is not mapped [from customer_info]; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: customer_info is not mapped [from customer_info]


 CusDAOimpl中HQL语句里

public List<CusInfo_fy> findALL() {
        String querystr="from customer_info";
        List<CusInfo_fy> list = (List<CusInfo_fy>) this.getHibernateTemplate().find(querystr);
        return list;
    }
customer_info是我数据库中的表名,但是应该写 在javaweb中需要映射的实体类 CusInfo

 2、对于数据库设置日期是date 但页面显示dateTime,注意映射文件中type是“java.sql.Date”,而不是“java.util.Date”

3、在数据库中我有进行外键约束但是一直报错:Cannot delete or update a parent row: a foreign key constraint fails

  解决方法:取消数据库中表的外键约束,在Dao文件中进行判断是否数据表中存在,存在则在action返回false,并提示用户错误页面。

4、如何在一个action执行完跳转实现另一个action

  通过Struts文件中设置<result name="success" type="redirect">/orderList.action</result>

5、在hibernate配置文件中,如果多个action关联同一个service,注意保持<property name="cusService" ref="cusService"></property>的一致,否则容易报错

  最好在action页面中自动生成service 的setter,否则容易找不到service的关联

6、我是采用一个action对应一个action文件,但是显得很啰嗦,一开始忘记了可以在Struts配置文件直接定义action 中method属性来实现多个action在一个文件中。

原文地址:https://www.cnblogs.com/Nora-F/p/8983700.html