论坛首页 入门技术论坛

Hibernate错误解决

浏览 2944 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (1) :: 隐藏帖 (1)
作者 正文
   发表时间:2009-05-19  
问题1:java.lang.IllegalArgumentException: argument type mismatch
错误原因:jsp页面中表单标记库类型与form表单的enctype属性值不匹配。
解决方法:设置正确的enctype属性值。
问题2:double impor 数据库表文件映射文件
解决方法:从新将该表从数据库中生成映射文件
问题3:org.hibernate.HibernateException: Found shared references to a collection
解决方法:
问题4:org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.ORM.Member#4]
解决方法:表示你所查询的记录中外键外键对应的记录不存在!所以如果要删除某个记录的话一定把其关联的表中的记录都要删掉!
问题5:
java.lang.Error: Unresolved compilation problem:
The method setLastDate(Timestamp) in the type Member is not applicable for the arguments (Date)
解决方法:表中datatime类型字段对应的持久化类中的变量类型应该设置为Data(设计到JAVA WEB开发中对时间的处理)
问题6:
java.lang.reflect.InvocationTargetException
解决方法:把诸如以上的小问题解决这个异常便不会被引发!
问题:Repeated column in mapping for entity: com.ORM.Topic column: topic_classID (should be mapped with insert="false" update="false")
解决方法:待解决
问题七:在配置项目时,需要为项目添加特定的数据库比如MySQL,就要在这个项目中的hibernate配置文件中配置特别注意:其中的URL要包含用户名和密码不然的话有时会连接不上。
比如:jdbc:mysql://localhost:3306/test?user=root&password=5769358&useUnicode=true&characterEncoding=gb2312
问题8:ESHop本事的sessionFactory有问题,正确的应该是:在代码收藏中。
问题9: Error parsing XML: XML InputStream(13) Attribute "generated" must be declared for element type "property".
解决:有关数据表映射文件中有关字段的设置出现问题把其改一下就行啦!
问题10:sesstionFactory创建失败的话会引起很多问题,因此一定要确保sesstionFactory被成功创建。
session的生命周期是整个会话过程,而Request的生命周期仅仅是一个请求周期,请求被处理后便自动消失。
问题11:deploy MyElipse项目时出现错误或者是部署失败!
解决:部署项目之前必须先把服务器关闭,然后在启动服务器,服务器启动的过程会把它里面的所有项目加载一遍。
问题12:java.lang.IllegalArgumentException: argument type mismatch
解决方法:因为我在表单中设置了一个Form类型的数据,因此应添加一句:enctype="multipart/form-data" 即使这个表单支持文件类型的或者其他多媒体类型数据
:配置Structs与Hibernate框架
配置Hibernate框架时驱动应该写成:String sConnStr="jdbc:mysql://localhost:3306/test?user=root&password=5769358&useUnicode=true&characterEncoding=gb2312";
否则的话有可能出现中文乱码的问题。
   发表时间:2009-05-20  
太详细了,不错!谢谢楼主分享
0 请登录后投票
   发表时间:2009-05-20  
org.springframework.orm.hibernate3.HibernateQueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from tw.com.synnex.competency.model.Duration where mtype = ? and ? between sdate and edate]; nested exception is org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from tw.com.synnex.competency.model.Duration where mtype = ? and ? between sdate and edate]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:640)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
at tw.com.synnex.competency.dao.hibernate.DurationDAOHibernate.between(DurationDAOHibernate.java:30)
Truncated. see log file for complete stacktrace

这个问题如何解决呢,我没有在spring整合hibernate的xml里面配置hibernate,我是Hibernate单独有配置文件,然后在spring配置文件里面引用
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value= "classpath:config/hibernate.cfg.xml" />
</bean>
0 请登录后投票
   发表时间:2009-05-20  
youjianbo_han_87 写道

org.springframework.orm.hibernate3.HibernateQueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from tw.com.synnex.competency.model.Duration where mtype = ? and ? between sdate and edate]; nested exception is org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from tw.com.synnex.competency.model.Duration where mtype = ? and ? between sdate and edate]at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:640)at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)at tw.com.synnex.competency.dao.hibernate.DurationDAOHibernate.between(DurationDAOHibernate.java:30)Truncated. see log file for complete stacktrace这个问题如何解决呢,我没有在spring整合hibernate的xml里面配置hibernate,我是Hibernate单独有配置文件,然后在spring配置文件里面引用&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;&lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="configLocation" value= "classpath:config/hibernate.cfg.xml" /&gt; &lt;/bean&gt;

我就看过Struct 1.X+hibernate,所以Spring不是太熟悉,临近期末也没有多少时间看,所以不能回答你的问题啊不好意思啊!不过凭感觉应该是有个类没有找到,是不是你没有导入那个类啊
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics