如题,我的表里有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 abstract class BaseCepUserFleet implements Serializable { public BaseCepUserFleet() { } public BaseCepUserFleet(Integer id) { this.id = id; } private Integer id; private Integer userId; private String userName; private String loginName; private String cardNumber; private Blob cardNumberScann; private BigDecimal carNum; private String legalCardNum; private String legalName; private Blob legalCardCopy; private String businessLicenseNum; private Blob businessLicenseScann; private String companyName; private String companyAddress; private String companyZipCode; private String companyPhone; private String companyFax; private String person; private String phone; private String mobile; private String email; private Date createTime; private Date updateTime; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getLoginName() { return loginName; } public void setLoginName(String loginName) { this.loginName = loginName; } public String getCardNumber() { return cardNumber; } public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; } public BigDecimal getCarNum() { return carNum; } public void setCarNum(BigDecimal carNum) { this.carNum = carNum; } public String getLegalCardNum() { return legalCardNum; } public void setLegalCardNum(String legalCardNum) { this.legalCardNum = legalCardNum; } public String getLegalName() { return legalName; } public void setLegalName(String legalName) { this.legalName = legalName; } public String getBusinessLicenseNum() { return businessLicenseNum; } public void setBusinessLicenseNum(String businessLicenseNum) { this.businessLicenseNum = businessLicenseNum; } public String getCompanyAddress() { return companyAddress; } public void setCompanyAddress(String companyAddress) { this.companyAddress = companyAddress; } public String getCompanyZipCode() { return companyZipCode; } public void setCompanyZipCode(String companyZipCode) { this.companyZipCode = companyZipCode; } public String getCompanyPhone() { return companyPhone; } public void setCompanyPhone(String companyPhone) { this.companyPhone = companyPhone; } public String getCompanyFax() { return companyFax; } public void setCompanyFax(String companyFax) { this.companyFax = companyFax; } public String getPerson() { return person; } public void setPerson(String person) { this.person = person; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getMobile() { return mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public String getCompanyName() { return companyName; } public void setCompanyName(String companyName) { this.companyName = companyName; } public Blob getCardNumberScann() { return cardNumberScann; } public void setCardNumberScann(Blob cardNumberScann) { this.cardNumberScann = cardNumberScann; } public Blob getLegalCardCopy() { return legalCardCopy; } public void setLegalCardCopy(Blob legalCardCopy) { this.legalCardCopy = legalCardCopy; } public Blob getBusinessLicenseScann() { return businessLicenseScann; } public void setBusinessLicenseScann(Blob businessLicenseScann) { this.businessLicenseScann = businessLicenseScann; }}package com.jeecms.cms.entity.cep;import java.math.BigDecimal;import java.sql.Blob;import java.util.Date;import com.jeecms.cms.entity.cep.base.BaseCepUserFleet;public class CepUserFleet extends BaseCepUserFleet { private static final long serialVersionUID = 1L; public CepUserFleet() { super(); }}