Hibernate保存对象奇怪问题疑是bug

  

       最近用webworkhibernate做开发,遇到一个超奇怪的问题,我甚至怀疑是hibernate的一个bug!做了一个用户注册功能,用TableMember对象保存用户的信息,由于要有密码提示问题和答案及找回密码的功能,TableMemberTUserQuestion为多对一的关系。在sql server2000数据库下一切正常;拿到linuxpgsql下发生了问题。问题发生在我用hibernatesaveOrUpdate()方法保存TableMember对象时,发生的错误如下:
[code]
2007-07-13 09:19:43,471 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 0, SQLState: null>

2007-07-13 09:19:43,471 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Batch entry 0 insert into com_crazyasp_rights_Member (userid, questionId, answer, username, uib_sex, uib_nickname, uib_realname, uib_birthday, uib_homeland, uib_height, uib_weigth, uib_tel, uib_mobile, uib_qq, uib_msn, uib_image, uib_email, uib_identity, uib_postalCode, uib_address, motto, id) values ( was aborted. Call getNextException() to see the cause.>

2007-07-13 09:19:43,471 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 0, SQLState: 42703>

2007-07-13 09:19:43,472 ERROR [org.hibernate.util.JDBCExceptionReporter] - <错误: 关系 "com_crazyasp_rights_member" "questionid" 字段不存在

><o:p> </o:p>

2007-07-13 09:19:43,474 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - <Could not synchronize database state with session>

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)

       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)

       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)

       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)

       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)

       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)

       at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:815)

       at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)

       at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:813)

       at com.crazyasp.common.TableOption.save(TableOption.java:175)
       补充一下:TableOption.java的175行就是hibernate的saveOrUpdate()方法!
[/code]

最直接的错误信息为:<错误: 关系 "com_crazyasp_rights_member" "questionid" 字段不存在,而事实上,数据表com_crazyasp_rights_member中有一个字段是questionId,注意I是大写的;当然映射文件中写的也是column=”questionId”,问题是为什么会出来这样的错误,questionid是哪里来的!
    
我没有办法,把数据库里的questionId字段强行改成了questionid字段,而映射文件里仍然写的是questionId,但这个问题就消失了!真搞不明白,为什么hibernate映射文件里写questionId到了pg数据库里就变成了questionid,等大家一起探讨吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值