Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring, Hibernate, Blob lazy loading
    primarykey
    data
    text
    <p>I need help with lazy blob loading in Hibernate. I have in my web application these servers and frameworks: MySQL, Tomcat, Spring and Hibernate.</p> <p>The part of database config.</p> <pre><code>&lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt; &lt;property name="user" value="${jdbc.username}"/&gt; &lt;property name="password" value="${jdbc.password}"/&gt; &lt;property name="driverClass" value="${jdbc.driverClassName}"/&gt; &lt;property name="jdbcUrl" value="${jdbc.url}"/&gt; &lt;property name="initialPoolSize"&gt; &lt;value&gt;${jdbc.initialPoolSize}&lt;/value&gt; &lt;/property&gt; &lt;property name="minPoolSize"&gt; &lt;value&gt;${jdbc.minPoolSize}&lt;/value&gt; &lt;/property&gt; &lt;property name="maxPoolSize"&gt; &lt;value&gt;${jdbc.maxPoolSize}&lt;/value&gt; &lt;/property&gt; &lt;property name="acquireRetryAttempts"&gt; &lt;value&gt;${jdbc.acquireRetryAttempts}&lt;/value&gt; &lt;/property&gt; &lt;property name="acquireIncrement"&gt; &lt;value&gt;${jdbc.acquireIncrement}&lt;/value&gt; &lt;/property&gt; &lt;property name="idleConnectionTestPeriod"&gt; &lt;value&gt;${jdbc.idleConnectionTestPeriod}&lt;/value&gt; &lt;/property&gt; &lt;property name="maxIdleTime"&gt; &lt;value&gt;${jdbc.maxIdleTime}&lt;/value&gt; &lt;/property&gt; &lt;property name="maxConnectionAge"&gt; &lt;value&gt;${jdbc.maxConnectionAge}&lt;/value&gt; &lt;/property&gt; &lt;property name="preferredTestQuery"&gt; &lt;value&gt;${jdbc.preferredTestQuery}&lt;/value&gt; &lt;/property&gt; &lt;property name="testConnectionOnCheckin"&gt; &lt;value&gt;${jdbc.testConnectionOnCheckin}&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" /&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="configLocation" value="/WEB-INF/hibernate.cfg.xml" /&gt; &lt;property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" /&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="lobHandler" ref="lobHandler" /&gt; &lt;/bean&gt; &lt;tx:annotation-driven transaction-manager="txManager" /&gt; &lt;bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; </code></pre> <p>The part of entity class</p> <pre><code>@Lob @Basic(fetch=FetchType.LAZY) @Column(name = "BlobField", columnDefinition = "LONGBLOB") @Type(type = "org.springframework.orm.hibernate3.support.BlobByteArrayType") private byte[] blobField; </code></pre> <p>The problem description. I'm trying to display on a web page database records related to files, which was saved in MySQL database. All works fine if a volume of data is small. But the volume of data is big I'm recieving an error <code>java.lang.OutOfMemoryError: Java heap space</code> I've tried to write in blobFields null values on each row of table. In this case, application works fine, memory doesn't go out of. I have a conclusion that the blob field which is marked as lazy (<code>@Basic(fetch=FetchType.LAZY)</code>) isn't lazy, actually!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload