Hibernate常见错误

Hibernate常见错误
1.错误:object references an unsaved transient instance - save the transient instance before flushing:

com.xxxx.bean.java.Sysblog; nested exception is org.hibernate.TransientObjectException: object references an unsaved

transient instance - save the transient instance before flushing: com.xxx.bean.java.Sysblog

解决方法:没有可预期的实例,当然就要实例化对象咯

2.错误:Exceptionobject references an unsaved transient instance - save the transient instance before flushing:

src.persistent.Product......

解决方法:原因没有为某对象进行set设置, 如上边的这个就是某对象没有调用setProduct

3.错误:Illegal attempt to associate a collection with two open sessions......

解决方法:(hibernate的session提供了一级缓存,每个session,对同一个id进行两次load,不会发送两条sql给数据库,但是session关闭的

时候,一级缓存就失效了。

sysblogarticle.setAmount(new Long(sysblogcommentService.selcom(
                  sysblogarticle.getArticleid().toString()).size()));//通过文章id获取文章评论数
           sysblogarticle.setSysblogcomments(null);//关键
           sysblogarticleService.saveOrUpdate(sysblogarticle);//将文章中评论条数修改
参考:http://javaflasher.javaeye.com/blog/forum/17913
 
4.错误:Hbm映射文件都生成好后,改数据库增加了默认值(如:将某个字段值设为1),结果在插入的时候,数据库那边没有反应。
 
解决方法: 在sql-type里面定义数据库默认值,那么SchemeExport的时候,DDL就会加上default。然后hbm定义为dynamic-insert="true"和

dynamic-update="true"
<hibernate-mapping>
  <class name="com.tom.hibernate.EbayItem" table="EBAY_ITEM" schema="API_USER" dynamic-insert="true" dynamic-update="true">
.......
........
<property name="viewData" not-null="true" type="boolean">    
    <column name="viewdata" sql-type="number(1) default 0"/>    
</property>  

</class>
</hibernate-mapping>


5.错误:
2008-2-2 9:45:13 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: Unknown column 'tjsaleresu0_.isupdate' in 'field list'
2008-2-2 9:45:13 org.hibernate.event.def.DefaultLoadEventListener onLoad
信息: Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [ookj.domain.TjSaleResult#293]


--数据库中没有“isupdate”字段


6.错误:
2008-2-2 9:51:42 org.hibernate.util.JDBCExceptionReporter logExceptions
警告: SQL Error: 1052, SQLState: 23000
2008-2-2 9:51:42 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: Column 'df' in where clause is ambiguous

————find("select tsr from TjSaleResult tsr, TjItemResult tir where tsr=tir.saleResultId and tir=? and df<>1", new Object

[]{tir});
————语句中的df不能确定是哪个表的

 
7.错误
org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: trackDate of:

ookj.domain.TjReagentTrack [from ookj.domain.TjReagentTrack trt where trt.trackStage=? and trt.trackDate=? and trt.userId=?

and trt.df<>1]; nested exception is org.hibernate.QueryException: could not resolve property: trackDate of:

ookj.domain.TjReagentTrack [from ookj.domain.TjReagentTrack trt where trt.trackStage=? and trt.trackDate=? and trt.userId=?

and trt.df<>1]
Caused by: org.hibernate.QueryException: could not resolve property: trackDate of: ookj.domain.TjReagentTrack [from

ookj.domain.TjReagentTrack trt where trt.trackStage=? and trt.trackDate=? and trt.userId=? and trt.df<>1]


————问题是配置中:
       private static String[][] properties={
          {"getReagentTrackId","reagent_trackid","0"},
          {"getReagentId","reagentid","1"},
          {"getUserId","userid","1"},
          {"getGuideBookId","guidebookid","1"},
          {"getTrackTime","tracktime","0"},                //这里名称不对
          {"trackStage","trackstage","0"},
          {"getDf","df","0"}
————还有nd trt.trackDate=? 语句中的值有误。

 

8.错误
java.lang.ClassCastException: ookj.domain.OokjDateTime

————基本的  类型转换错误


9.错误
org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the

transient instance before flushing: ookj.domain.SmDept; nested exception is org.hibernate.TransientObjectException: object

references an unsaved transient instance - save the transient instance before flushing: ookj.domain.SmDept
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient

instance before flushing: ookj.domain.SmDept

————new了一个新对象,在未保存之前将它保存进了一个新new的对象。

10.错误
信息: could not read column value from result set: activep19_59_; could not deserialize
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: could not deserialize; nested

exception is org.hibernate.type.SerializationException: could not deserialize
Caused by: org.hibernate.type.SerializationException: could not deserialize

我用的数据库是mysql,在通过pojo类自动生成的类中,未为字段指定type,hibernate对自动为其指定,如果它所生成的type不能被反序列化

,就会抛出java.util.ServilizableException

比如我产生异常的原因是我建立了一个string[]类型的字段,但在对应的.hbm.xml文件中我没有显式定义它的类型,hibernate自动为其指定了

类型,该类型不能被反序列化。

11.错误
严重: line 1:143: expecting IDENT, found '.'
2008-2-3 0:41:01 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet tijianServlet threw exception
org.springframework.orm.hibernate3.HibernateQueryException: expecting IDENT, found '.' near line 1, column 143 [select

t.saleItemId.medicalGroup from ookj.domain.TjSaleResult t where t.guideBookId=? and t.saleItemId.medicalGroup.block=? and

t.saleItemId..medicalGroup.df<>1]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found '.'

near line 1, column 143 [select t.saleItemId.medicalGroup from ookj.domain.TjSaleResult t where t.guideBookId=? and

t.saleItemId.medicalGroup.block=? and t.saleItemId..medicalGroup.df<>1]
Caused by: org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found '.' near line 1, column 143 [select

t.saleItemId.medicalGroup from ookj.domain.TjSaleResult t where t.guideBookId=? and t.saleItemId.medicalGroup.block=? and

t.saleItemId..medicalGroup.df<>1]

_____多了一个点

 
12.错误
java.net.SocketException: java.net.ConnectException: Connection refused: connect


————数据库未启动

 
13.错误
严重: Servlet.service() for servlet tijianServlet threw exception
java.lang.NoSuchMethodError: ookj.service.SendReagentService.saveTjSendReagent

(Lookj/domain/TjReagent;Lookj/domain/SaleGuideBook;)[Ljava/lang/String;

————Tomcat/Java虚拟集中代码未跟上,不能保持同步,重启虚拟机就好了。


偶嘀错误集合 [转贴 2007-03-04 15:19:00]  
 
1. 做Hibernate多对一的时候遇到错误

(1)org.apache.jasper.JasperException: Error creating bean with name 'sf' defined in ServletContext resource [/WEB-

INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException:

Could not find a getter for person in class com.accp.vo.Course

因为配置文件中的一个 <many-to-one name="person"  ../>  中的person属性名称写错了.


还有原因如下:
    1)getter()方法写错了,没有按照javaBean的规则写.
    2)*.hmb.xml中的属性名和pojo中的是否一致.注意:属性名是否多了空格.


(2).Hibernate多对一报错:

save the transient instance before flushing

具体错误为在one-to-many中,对many进行save时,由于没有加入one的外建,导致错误。
具体解决方法:
(1)、在one的hbm文件中 invest=true
(2)、在many保存前务必要求one的存在

 
2.spring+struts+hibernate 项目debug总结
(1) javax.servlet.ServletException: Cannot retrieve mapping for action /companyNews
    struts-config.xml中没有写相关companyNews的action.

(2)  在myeclipse增加一个jar包时候,先打开项目properties,选择java build path --> libraries -->add external JARs 选择到需要的

jar包,加入后,发现,他这个包加载的是绝对路径,而我们的项目需要cvs共享,无法commit到cvs服务器。myeclipse有以下提示信息:
    2 build path entries are missing.

    解决办法是,关闭myeclipse,用notepad打开项目目录下的 .classpath, 手动修改成相对路径,并且检 查,指定的相对路径中是否真正添

加了jar包,启动myeclipse就可以上传新添加的jar包了。

(3)  在使用junit/StrutsTest时候,报错:
java.lang.UnsupportedClassVersionError: junit/framework/TestListener (Unsupported major.minor version 49.0)

     原因是如果是jdk1.4的话,只能使用junit3.8以下版本,如果是使用jdk1.5的话,必须使用junit4.0 以上版本。

 

(4)  Cannot find ActionMappings or ActionformBeans collection
    原因是:web.xml文件中没有配置struts-config.xml的相关信息。

(5) org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml

or the jar files deployed with this application


缺少jstl的相关jar和web.xml配置
jstl.jar
<taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
    <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
    <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
    <taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
    <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
    <taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
    <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
</taglib>


(5)  Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
standard.jar没有放在lib里面


(6)  创建oracle表的时候,使用了,role和comment关键字,建议不要将这两个关键字作为表名和字段名。
建议用toad或plsql developer创建表,这样软件会提示关键字。


(7)  [ERROR] XMLHelper - Error parsing XML: XML InputStream(18) Attribute name "column" associated with an element type "key"

must be followed by the ' = ' character.
[ERROR] Configuration - Could not configure datastore from input stream <org.dom4j.DocumentException: Error on line 18 of

document  : Attribute name "column" associated with an element type "key"

must be followed by the ' = ' character. Nested exception: Attribute name "column" associated with an element type "key" must

be followed by the ' = ' character.>org.dom4j.DocumentException: Error

on line 18 of document  : Attribute name "column" associated with an element type "key" must be followed by the ' = '

character. Nested exception: Attribute name "column" associated with an element

type "key" must be followed by the ' = ' character.

xml 语法错误,key语法中应该类似这样的写法 <key column="id">


(8) hibernate3,对象中一对多的one方,必须写private Set pays=new HashSet();,否则包错java.lang.NullPointerException ,
而hibernate2中private Set pays;却不报错;

(9) [DEBUG] AbstractSaveEventListener - generated identifier: 1, using strategy: org.hibernate.id.IncrementGenerator
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.xxx.yyy.company
 at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)

<many to one >中的设置应该设置为not-null="false" ,设置为not-null="true"则报以上错误


(10) org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance

before flushing: com.xxx.yyy.Company

在save的同时也需要save其他的表,然后再flush()


(11) Parse Fatal Error at line 12 column 1

struts-config.xml文件被修改,语法错误。检查语法。

(12)org.hibernate.QueryException: could not resolve property: userid of:

com.xxx.yyy.Pay

使用到外键userid的时候,必须使用userinfo.userid方法才能得到。

(13)javax.naming.NameNotFoundException: Name hibernate_connection_factory is not

bound in this Context 原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。
例如many-to-one设置了以后,仍然在其中设置相冲突的<property>属性。

(14) [WARN] RequestProcessor - Unhandled Exception thrown: class java.lang.NullPointerException
必须将使用到的对象new起来。

(15) GROUP BY 表达式的查询必须满足如下:
select 子句后的每一项必需出现在group by 子句中,除非该项使用了聚集函数。

(16) org.hibernate.TransientObjectException: object references an unsaved transient

instance - save the transient instance before flushing: com.xxx.yyy.Company

要级联保存,多次session.save()
(17)
java.lang.IllegalArgumentException: id to load is required for loading
原因:

session.load(Company.class,payForm.getCompanyId());
load()方法第二个参数必须是searlizable,并且必须是和数据库映射类的属性值类型一致,即使强制转换都不行。

(18) [INFO] DefaultLoadEventListener - Error performing load command <org.hibernate.ObjectNotFoundException: No row with the

given identifier exists: [com.xxx.yyy.Company#0]

>org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xxx.yyy.Company#0]
表示你现在查询的对象所关联的对象有问题,一般是因为数据的问题(该对象所关联的对象找不到),数据的错误,影响了程序正常执行。

(19)
eclipse 3.1,myeclipse 4错误
Deployment is out of date due to changes in the underlying project contents . You'll need to mannally 'Redeploy' the project

to update the deployed archive.
原因
tomcat 中部署的某个文件的拒绝访问影响了部署。
重启后,去除tomcat中部署的文件。重新在eclipse中设置部署。
为什么需要重启?
因为:google desktop软件正在对我部署的一个300MB大文件进行索引,锁定了这个大文件,我估计google desktop需要对这个文件索引半个小

时以上。因此,eclipse无法对过去部署的文件,做先删除后重新部署的工作。

(20) ERROR LazyInitializationException:19 - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
解决办法。
 cmpy=(CompanyEdit)ss.load(CompanyEdit.class,companyId1);
   Hibernate.initialize(cmpy);//强制初始化cmpy,否则ss.close()后,cmpy将消失.

(21) javascript错误
行: 56
字符: 45
错误: 未结束的字符串常量
代码: 0

是编码的问题!用ANSI编码另存后就好了。

(22) [WARN] JDBCExceptionReporter - SQL Error: 904, SQLState: 42000
[ERROR] JDBCExceptionReporter - ORA-00904: 无效列名 [INFO] DefaultLoadEventListener - Error performing load command

<org.hibernate.exception.SQLGrammarException: could not load an entity: [com.xxx.yyy.Sellinfo#1]

>org.hibernate.exception.SQLGrammarException: could not load an entity: [com.xxx.yyy.Sellinfo#1]

***.hbm.xml文件中的某个列名和数据库中的不同。

(23) ConnectionManager - unclosed connection, forgot to call close() on your session?


原因:没有关闭hibernate的session的transaction。或者没有关闭session

(24) [WARN] SellCommentDAO - org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove

deleted object from associations): [com.xxx.yyy.SellComment#7]

原因:父亲对象(one方)设置cascade="save-update" 时,直接删除子对象时,会报错,
处理方法:save信息需要级联操作,delete时候也要用相同的原理。
SellComment sellComment=new SellComment();
sellComment = (SellComment)session.load(SellComment.class,sellCommentId);//获取儿子对象
Long sellInfoId=sellComment.getSellInfo().getSellId();//获取父亲id
SellInfo sellinfo=(SellInfo)session.load(SellInfo.class,sellInfoId);//获取父亲对象
sellInfo.getSellComments().remove(sellComment);//断绝父子关系
sellComment.setSellInfo(null);//断绝子父关系
session.delete(sellComment);//删除儿子
session.flush();


偶嘀错误集合 [转贴 2007-03-04 15:19:00]  
 
1. 做Hibernate多对一的时候遇到错误

(1)org.apache.jasper.JasperException: Error creating bean with name 'sf' defined in ServletContext resource [/WEB-

INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.PropertyNotFoundException:

Could not find a getter for person in class com.accp.vo.Course

因为配置文件中的一个 <many-to-one name="person"  ../>  中的person属性名称写错了.


还有原因如下:
    1)getter()方法写错了,没有按照javaBean的规则写.
    2)*.hmb.xml中的属性名和pojo中的是否一致.注意:属性名是否多了空格.


(2).Hibernate多对一报错:

save the transient instance before flushing

具体错误为在one-to-many中,对many进行save时,由于没有加入one的外建,导致错误。
具体解决方法:
(1)、在one的hbm文件中 invest=true
(2)、在many保存前务必要求one的存在

 
2.spring+struts+hibernate 项目debug总结
(1) javax.servlet.ServletException: Cannot retrieve mapping for action /companyNews
    struts-config.xml中没有写相关companyNews的action.

(2)  在myeclipse增加一个jar包时候,先打开项目properties,选择java build path --> libraries -->add external JARs 选择到需要的

jar包,加入后,发现,他这个包加载的是绝对路径,而我们的项目需要cvs共享,无法commit到cvs服务器。myeclipse有以下提示信息:
    2 build path entries are missing.

    解决办法是,关闭myeclipse,用notepad打开项目目录下的 .classpath, 手动修改成相对路径,并且检 查,指定的相对路径中是否真正添

加了jar包,启动myeclipse就可以上传新添加的jar包了。

(3)  在使用junit/StrutsTest时候,报错:
java.lang.UnsupportedClassVersionError: junit/framework/TestListener (Unsupported major.minor version 49.0)

     原因是如果是jdk1.4的话,只能使用junit3.8以下版本,如果是使用jdk1.5的话,必须使用junit4.0 以上版本。

 

(4)  Cannot find ActionMappings or ActionformBeans collection
    原因是:web.xml文件中没有配置struts-config.xml的相关信息。

(5) org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml

or the jar files deployed with this application


缺少jstl的相关jar和web.xml配置
jstl.jar
<taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
    <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
    <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
    <taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
    <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
    <taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
    <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
</taglib>


(5)  Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV
standard.jar没有放在lib里面


(6)  创建oracle表的时候,使用了,role和comment关键字,建议不要将这两个关键字作为表名和字段名。
建议用toad或plsql developer创建表,这样软件会提示关键字。


(7)  [ERROR] XMLHelper - Error parsing XML: XML InputStream(18) Attribute name "column" associated with an element type "key"

must be followed by the ' = ' character.
[ERROR] Configuration - Could not configure datastore from input stream <org.dom4j.DocumentException: Error on line 18 of

document  : Attribute name "column" associated with an element type "key"

must be followed by the ' = ' character. Nested exception: Attribute name "column" associated with an element type "key" must

be followed by the ' = ' character.>org.dom4j.DocumentException: Error

on line 18 of document  : Attribute name "column" associated with an element type "key" must be followed by the ' = '

character. Nested exception: Attribute name "column" associated with an element

type "key" must be followed by the ' = ' character.

xml 语法错误,key语法中应该类似这样的写法 <key column="id">


(8) hibernate3,对象中一对多的one方,必须写private Set pays=new HashSet();,否则包错java.lang.NullPointerException ,
而hibernate2中private Set pays;却不报错;

(9) [DEBUG] AbstractSaveEventListener - generated identifier: 1, using strategy: org.hibernate.id.IncrementGenerator
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.xxx.yyy.company
 at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)

<many to one >中的设置应该设置为not-null="false" ,设置为not-null="true"则报以上错误


(10) org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance

before flushing: com.xxx.yyy.Company

在save的同时也需要save其他的表,然后再flush()


(11) Parse Fatal Error at line 12 column 1

struts-config.xml文件被修改,语法错误。检查语法。

(12)org.hibernate.QueryException: could not resolve property: userid of:

com.xxx.yyy.Pay

使用到外键userid的时候,必须使用userinfo.userid方法才能得到。

(13)javax.naming.NameNotFoundException: Name hibernate_connection_factory is not

bound in this Context 原因:hibernate的数据库映射.xml文件有配置错误,导致hibernate_connection_factory无法绑定数据库。
例如many-to-one设置了以后,仍然在其中设置相冲突的<property>属性。

(14) [WARN] RequestProcessor - Unhandled Exception thrown: class java.lang.NullPointerException
必须将使用到的对象new起来。

(15) GROUP BY 表达式的查询必须满足如下:
select 子句后的每一项必需出现在group by 子句中,除非该项使用了聚集函数。

(16) org.hibernate.TransientObjectException: object references an unsaved transient

instance - save the transient instance before flushing: com.xxx.yyy.Company

要级联保存,多次session.save()
(17)
java.lang.IllegalArgumentException: id to load is required for loading
原因:

session.load(Company.class,payForm.getCompanyId());
load()方法第二个参数必须是searlizable,并且必须是和数据库映射类的属性值类型一致,即使强制转换都不行。

(18) [INFO] DefaultLoadEventListener - Error performing load command <org.hibernate.ObjectNotFoundException: No row with the

given identifier exists: [com.xxx.yyy.Company#0]

>org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.xxx.yyy.Company#0]
表示你现在查询的对象所关联的对象有问题,一般是因为数据的问题(该对象所关联的对象找不到),数据的错误,影响了程序正常执行。

(19)
eclipse 3.1,myeclipse 4错误
Deployment is out of date due to changes in the underlying project contents . You'll need to mannally 'Redeploy' the project

to update the deployed archive.
原因
tomcat 中部署的某个文件的拒绝访问影响了部署。
重启后,去除tomcat中部署的文件。重新在eclipse中设置部署。
为什么需要重启?
因为:google desktop软件正在对我部署的一个300MB大文件进行索引,锁定了这个大文件,我估计google desktop需要对这个文件索引半个小

时以上。因此,eclipse无法对过去部署的文件,做先删除后重新部署的工作。

(20) ERROR LazyInitializationException:19 - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
解决办法。
 cmpy=(CompanyEdit)ss.load(CompanyEdit.class,companyId1);
   Hibernate.initialize(cmpy);//强制初始化cmpy,否则ss.close()后,cmpy将消失.

(21) javascript错误
行: 56
字符: 45
错误: 未结束的字符串常量
代码: 0

是编码的问题!用ANSI编码另存后就好了。

(22) [WARN] JDBCExceptionReporter - SQL Error: 904, SQLState: 42000
[ERROR] JDBCExceptionReporter - ORA-00904: 无效列名 [INFO] DefaultLoadEventListener - Error performing load command

<org.hibernate.exception.SQLGrammarException: could not load an entity: [com.xxx.yyy.Sellinfo#1]

>org.hibernate.exception.SQLGrammarException: could not load an entity: [com.xxx.yyy.Sellinfo#1]

***.hbm.xml文件中的某个列名和数据库中的不同。

(23) ConnectionManager - unclosed connection, forgot to call close() on your session?


原因:没有关闭hibernate的session的transaction。或者没有关闭session

(24) [WARN] SellCommentDAO - org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove

deleted object from associations): [com.xxx.yyy.SellComment#7]

原因:父亲对象(one方)设置cascade="save-update" 时,直接删除子对象时,会报错,
处理方法:save信息需要级联操作,delete时候也要用相同的原理。
SellComment sellComment=new SellComment();
sellComment = (SellComment)session.load(SellComment.class,sellCommentId);//获取儿子对象
Long sellInfoId=sellComment.getSellInfo().getSellId();//获取父亲id
SellInfo sellinfo=(SellInfo)session.load(SellInfo.class,sellInfoId);//获取父亲对象
sellInfo.getSellComments().remove(sellComment);//断绝父子关系
sellComment.setSellInfo(null);//断绝子父关系
session.delete(sellComment);//删除儿子
session.flush();

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页