Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading BLOB table from H2 embedded with Hibernate
    primarykey
    data
    text
    <p>I have an application that has to run with an Oracle or embedded H2 database depending on the environment. Up till now I used a MySQL database instead of the embedded H2 one, but decided to migrate. </p> <p>I use Hibernate 3.3.1GA (and am restricted, so I cannot update). With both Oracle and MySQL everything works fine, but when I try to use the H2 database it keeps hanging. The problem appears to be a column with BLOBs (serialized java objects). Even when the table is empty, execution hangs. </p> <p>SLF4J output (loglevel ALL):</p> <pre><code>TableMetadata.java:org.hibernate.tool.hbm2ddl.TableMetadata:&lt;init&gt;:62 INFO table found: DATABASE.PUBLIC.JAVA_OBJECTS org.hibernate.tool.hbm2ddl.TableMetadata:&lt;init&gt;:63 INFO columns: [id, last_update, markdeleted, class, object] org.hibernate.connection.DriverManagerConnectionProvider:closeConnection:152 TRACE returning connection to pool, pool size: 1 </code></pre> <p>At this point the program seems to hang. Earlier log output seems normal and when this table is not used (removed from hibernate.cfg.xml) the program starts up fine.</p> <p>hibernate.cfg.xml (excerpt)</p> <pre><code>&lt;property name="hibernate.connection.driver_class"&gt;org.h2.Driver&lt;/property&gt; &lt;property name="hibernate.connection.url"&gt;jdbc:h2:file:database&lt;/property&gt; &lt;property name="hibernate.connection.username"&gt;sa&lt;/property&gt; &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt; &lt;property name="hibernate.default_schema"&gt;PUBLIC&lt;/property&gt; &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.H2Dialect&lt;/property&gt; &lt;property name="connection.pool_size"&gt;1&lt;/property&gt; &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt; &lt;property name="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt; </code></pre> <p>The table's create string:</p> <pre><code>CREATE TABLE java_objects ( id int(11) NOT NULL AUTO_INCREMENT, class varchar(255) NOT NULL, object blob NOT NULL, last_update timestamp AS CURRENT_TIMESTAMP, markDeleted tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (id) ) ; </code></pre> <p>and finally the entity xml</p> <pre><code>&lt;hibernate-mapping&gt; &lt;class name="server.DataBean" table="java_objects"&gt; &lt;id name="id" column="id"&gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;property name="type" column="class" /&gt; &lt;property name="object" not-null="true"&gt; &lt;column name="object" sql-type="BLOB" /&gt; &lt;/property&gt; &lt;property name="lastUpdate" column="last_update" type="timestamp" /&gt; &lt;property name="markDeleted" type="boolean" /&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Does anyone know what I'm doing wrong? What is h2 expecting differently when handling blobs?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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