在Mysql中合并LONGBLOB对象时,在java编程中堆内存

时间:2014-01-09 08:27:05

标签: java mysql hibernate

堆栈是:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    at org.hibernate.type.ByteArrayBlobType.deepCopy(ByteArrayBlobType.java:76)
    at org.hibernate.type.ByteArrayBlobType.replace(ByteArrayBlobType.java:189)
    at org.hibernate.type.AbstractType.replace(AbstractType.java:177)
    at org.hibernate.type.TypeFactory.replace(TypeFactory.java:538)
    at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:429)
    at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:231)
    at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
    at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:714)
    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:696)
    at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:268)
    at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:291)
    at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:239)
    at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:192)
    at org.hibernate.engine.Cascade.cascade(Cascade.java:153)
    at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:454)
    at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:230)
    at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
    at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:714)
    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:696)
    at org.hibernate.engine.CascadingAction$6.cascade(CascadingAction.java:268)
    at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:291)
    at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:239)
    at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:192)
    at org.hibernate.engine.Cascade.cascade(Cascade.java:153)
    at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:454)
    at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:230)
    at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
    at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:81)
    at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:704)
    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)
    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)
    at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:228)

制作大量代码来描述这个问题有点困难,但我会尝试解释我的内容:

我有一个对象A,对象foreign key上有B,实际上是保存在xml db上的Mysql文件为LONGBlob

当我尝试merge(通过hibernate)对象A时,错误适用。

我尝试将JVM eclipse的内存参数更改为:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms256m
-Xmx1024m

我希望我已经解释了我的问题

1 个答案:

答案 0 :(得分:1)

您似乎已经调整了Eclipse JVM内存设置(您正在编辑eclipse.ini文件),而不是您的应用程序。您应该在Eclipse运行配置视图中增加Java应用程序的堆大小。

此外,您还应考虑使用高内存资源的延迟加载实体(在本例中为B)。