日期:2014-05-17  浏览次数:20793 次

hibernate保存多张图片到oracle数据库的blob字段问题
如题,我的表里有3个blob字段,需求用户同时上传这3张图片到数据库,但是上传之后,发现图片位置借位,第一张和最后一张图片会互换位置,我仔细查看代码没有发现问题,经过多次测试发现当上传>=2张图片的时候会发生这种问题,测试通过针对其中某一个字段单个保存可以正常保存,但是当>=2张时会出现上面问题。
下面是hibernate配置文件
XML code

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.jeecms.cms.entity.cep">
    <class name="CepUserFleet" table="T_USER_FLEET">
        <id name="id" type="java.lang.Integer" column="id">
            <generator class="sequence"><param name="sequence">T_USER_FLEET_SEQ</param></generator>
        </id>
        <property name="userId" column="USER_ID" type="java.lang.Integer" not-null="true" />
        <property name="loginName" column="LOGIN_NAME" type="string" not-null="true" />
        <property name="userName" column="USER_NAME" type="string" not-null="true" />
        <property name="cardNumber" column="CARD_NUMBER" type="string" />
        <property name="cardNumberScann" column="CARD_NUMBER_SCANN" type="java.sql.Blob" />
        <property name="carNum" column="CAR_NUM" type="java.math.BigDecimal" />
        <property name="legalCardNum" column="LEGAL_CARD_NUM" type="string" />
        <property name="legalName" column="LEGAL_NAME" type="string" />
        <property name="legalCardCopy" column="LEGAL_CARD_COPY" type="java.sql.Blob" />
        <property name="businessLicenseNum" column="BUSINESS_LICENSE_NUM" type="string" />
        <property name="businessLicenseScann" column="BUSINESS_LICENSE_SCANN" type="java.sql.Blob" />
        <property name="companyName" column="COMPANY_NAME" type="string" />
        <property name="companyAddress" column="COMPANY_ADDRESS" type="string" />
        <property name="companyZipCode" column="COMPANY_ZIPCODE" type="string" />
        <property name="companyPhone" column="COMPANY_PHONE" type="string" />
        <property name="companyFax" column="COMPANY_FAX" type="string" />
        <property name="person" column="PERSON" type="string" />
        <property name="phone" column="PHONE" type="string" />
        <property name="email" column="EMAIL" type="string" />
        <property name="mobile" column="MOBILE" type="string" />
        <property name="createTime" column="CREATE_TIME" type="timestamp" length="19"/>
        <property name="updateTime" column="UPDATE_TIME" type="timestamp" length="19"/>
    </class>
</hibernate-mapping>



Entity类如下:
Java code

package com.jeecms.cms.entity.cep.base;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Blob;
import java.util.Date;

public abstra