在服务器休眠中部署时,表不存在

时间:2013-07-19 10:23:09

标签: java mysql hibernate

当我在测试服务器上部署Web应用程序时(它在localhost上运行正常),这个BLO_BlOCKED_MOBILES表位于给定的代码行。

Query query = this.getSession().createSQLQuery(
            strQuery.append(" INSERT INTO BLO_BlOCKED_MOBILES (BLO_CUSTOMER_ID_FK,BLO_MOBILE,BLO_NEWMOBILE,BLO_PASSPORT,BLO_STATUS,BLOCKED_BY,BLOCKED_AT ) "
             +"VALUES( "+customer.getId() +", '"+ oldMobile +"','"+newMobile+"','"+customer.getPassportNo()+"','Y','user',CURRENT_TIMESTAMP)" ).toString());
    mtmrsLogger.info(query.toString());
    int affectedRows = query.executeUpdate(); 

db在mysql中,app使用hibernate,struts 1和spring。我创建了这个新表, 在hibernate.cfg.xml上添加了这个

 < mapping class="com.mtmrs.model.branch.BlockedMobile"/>

并创建模型文件BlockedMobile.java

当使用它时,会出现以下错误。

WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 1146, SQLState: 42S02
ERROR org.hibernate.util.JDBCExceptionReporter  - Table 'merchantrade.blo_blocked_mobiles' doesn't exist

如果信息不足,请告诉我。我没有看到什么是错的。

2 个答案:

答案 0 :(得分:0)

Peraphs这两个DB(在您的localhost服务器和测试服务器上)是不同的。所以测试服务器还没有你的表。

答案 1 :(得分:0)

根据错误消息,测试服务器上的MySQL数据库中不存在表blo_blocked_mobiles或方案merchantrade