Selecting Blobs in MyBatis

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Selecting Blobs in MyBatis

Fadye
I'm running into another issue during my iBatis to myBatis migration.
I have a select statement that selects a row in a table:

<select id="getSingleBackupRow"
resultMap="abatorgenerated_BackupResult"  parameterType="Backup">
    select top 1 BACKUP_ID, TABLE_NAME, ITEM_NAME, ITEM_VALUE,
ITEM_DIGEST, CREATED, MODIFIED, SCHEMA_VERSION, DEVICE_ID
    from BACKUPS with (NOLOCK)
    where BACKUP_ID = #{backupId}
    order by MODIFIED desc, CREATED desc
  </select>

Here's the resultmap:
  <resultMap id="abatorgenerated_BackupResult" type="Backup" >
    <result column="BACKUP_ID" property="backupId" jdbcType="BIGINT" /
>
    <result column="TABLE_NAME" property="tableName"
jdbcType="VARCHAR"/>
    <result column="ITEM_NAME" property="itemName" jdbcType="INTEGER" /
>
    <result column="ITEM_VALUE" property="itemValue" jdbcType="BLOB" /
>
    <result column="ITEM_DIGEST" property="itemDigest"
jdbcType="VARCHAR" />
    <result column="CREATED" property="created" jdbcType="TIMESTAMP" /
>
    <result column="MODIFIED" property="modified"
jdbcType="TIMESTAMP" />
    <result column="SCHEMA_VERSION" property="schemaVersion"
jdbcType="VARCHAR" />
    <result column="DEVICE_ID" property="deviceId" jdbcType="BIGINT"/>
  </resultMap>

When using iBatis, the following line:
<result column="ITEM_VALUE" property="itemValue" jdbcType="BLOB" />
was
<result column="ITEM_VALUE" property="itemValue" jdbcType="IMAGE" />

The issue now is that myBatis can't select the ITEM_VALUE. If i remove
it from my SQL Statement, it returns the object without any issues,
but if I put ITEM_VALUE back, I get the following error:
### Error querying database.  Cause: java.sql.SQLException: [Microsoft]
[SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for
column 1.
### The error may involve BACKUP.getSingleBackupRow-Inline
### The error occurred while setting parameters
### Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver
for JDBC]ResultSet can not re-read row data for column 1.

As far as I can tell, I'm only reading the data once. I have been
having this issue for the past two days. Any help would be greatly
appreciated.
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Selecting Blobs in MyBatis

Fadye
Nevermind this had nothing to do with myBatis. I needed to update my
JDBC Driver. Please delete post. Thank You

On Oct 28, 11:19 am, Fadye <[hidden email]> wrote:

> I'm running into another issue during my iBatis to myBatis migration.
> I have a select statement that selects a row in a table:
>
> <select id="getSingleBackupRow"
> resultMap="abatorgenerated_BackupResult"  parameterType="Backup">
>     select top 1 BACKUP_ID, TABLE_NAME, ITEM_NAME, ITEM_VALUE,
> ITEM_DIGEST, CREATED, MODIFIED, SCHEMA_VERSION, DEVICE_ID
>     from BACKUPS with (NOLOCK)
>     where BACKUP_ID = #{backupId}
>     order by MODIFIED desc, CREATED desc
>   </select>
>
> Here's the resultmap:
>   <resultMap id="abatorgenerated_BackupResult" type="Backup" >
>     <result column="BACKUP_ID" property="backupId" jdbcType="BIGINT" /
>
>     <result column="TABLE_NAME" property="tableName"
> jdbcType="VARCHAR"/>
>     <result column="ITEM_NAME" property="itemName" jdbcType="INTEGER" /
>
>     <result column="ITEM_VALUE" property="itemValue" jdbcType="BLOB" /
>
>     <result column="ITEM_DIGEST" property="itemDigest"
> jdbcType="VARCHAR" />
>     <result column="CREATED" property="created" jdbcType="TIMESTAMP" /
>
>     <result column="MODIFIED" property="modified"
> jdbcType="TIMESTAMP" />
>     <result column="SCHEMA_VERSION" property="schemaVersion"
> jdbcType="VARCHAR" />
>     <result column="DEVICE_ID" property="deviceId" jdbcType="BIGINT"/>
>   </resultMap>
>
> When using iBatis, the following line:
> <result column="ITEM_VALUE" property="itemValue" jdbcType="BLOB" />
> was
> <result column="ITEM_VALUE" property="itemValue" jdbcType="IMAGE" />
>
> The issue now is that myBatis can't select the ITEM_VALUE. If i remove
> it from my SQL Statement, it returns the object without any issues,
> but if I put ITEM_VALUE back, I get the following error:
> ### Error querying database.  Cause: java.sql.SQLException: [Microsoft]
> [SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for
> column 1.
> ### The error may involve BACKUP.getSingleBackupRow-Inline
> ### The error occurred while setting parameters
> ### Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver
> for JDBC]ResultSet can not re-read row data for column 1.
>
> As far as I can tell, I'm only reading the data once. I have been
> having this issue for the past two days. Any help would be greatly
> appreciated.
> Thanks