title: JPA Hibernate HSQLDB - VARBINARY() field and error attempting to select
body: <p>I found a similar question at <a href="https://stackoverflow.com/questions/3323681">HSQLDB: Duplicate column name, unsupported internal operation: Type, invalid character for cast</a>, but there was no intelligible answer. I also looked at <a href="http://old.nabble.com/unsupported-internal-operation%3A-StatementDMQL-td27427172.html" rel="nofollow noreferrer">http://old.nabble.com/unsupported-internal-operation%3A-StatementDMQL-td27427172.html</a> which reports the issue is a bug in HSQLDB, but it should be fixed in the version I am using (2.2). So, here's the details of the problem:</p>
  
  <p>I have an entity which stores some byte[] data in a VARBINARY(128) field inside of HSQLDB. The table is created successfully, but when I try to select from the table, I get the following stack trace:</p>
  
  <pre><code>java.sql.SQLException: java.lang.RuntimeException: unsupported internal operation: Type java.lang.RuntimeException: unsupported internal operation: Type
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source)
      at org.hsqldb.jdbc.JDBCPreparedStatement.executeQuery(Unknown Source)
      at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
      at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
      at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
      at org.hibernate.loader.Loader.doQuery(Loader.java:802)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
      at org.hibernate.loader.Loader.doList(Loader.java:2533)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
      at org.hibernate.loader.Loader.list(Loader.java:2271)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
      at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:274)
      at com.dns.recursive.ipcache.data.CacheWrapper.findEntry(CacheWrapper.java:206)
      at com.dns.recursive.ipcache.net.TCPWorker.run(TCPWorker.java:114)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:636)
  Caused by: org.hsqldb.HsqlException: java.lang.RuntimeException: unsupported internal operation: Type
      at org.hsqldb.error.Error.error(Unknown Source)
      at org.hsqldb.result.Result.newErrorResult(Unknown Source)
      at org.hsqldb.StatementDMQL.execute(Unknown Source)
      at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
      at org.hsqldb.Session.execute(Unknown Source)
      ... 21 more
  Caused by: java.lang.RuntimeException: unsupported internal operation: Type
      at org.hsqldb.error.Error.runtimeError(Unknown Source)
      at org.hsqldb.types.Type.subtract(Unknown Source)
      at org.hsqldb.ExpressionArithmetic.getValue(Unknown Source)
      at org.hsqldb.ExpressionOrderBy.getValue(Unknown Source)
      at org.hsqldb.QuerySpecification.buildResult(Unknown Source)
      at org.hsqldb.QuerySpecification.getSingleResult(Unknown Source)
      at org.hsqldb.QuerySpecification.getResult(Unknown Source)
      at org.hsqldb.StatementQuery.getResult(Unknown Source)
      ... 24 more
  </code></pre>
  
  <p>I could really use some help in figuring out the cause of this. Thanks in advance!!</p>