Hibernate+Spring映射Blob字段

1.SheetFile.java

package com.iman.nrms.nrmcs.common.domain.model.sheet;

import java.io.Serializable;

/**
* @hibernate.meta attribute="class-description" value="上传文件表"
* @hibernate.class table="NRMCS_SHEET_FILE"
* @hibernate.mapping default-lazy="false"
*/
public class SheetFile implements Serializable {

private static final long serialVersionUID = -3496721369104496832L;

private String id; // 主键

private String baseSheetId; // 工单ID

private String realName; // 原来文件名称

private String fileName; // 文件名称

private String sheetType; // 工单类型

private String stepName; // 步骤名称

private Long userId; // 上传人ID

private String userName; // 上传人名称

private String virtual; // 虚拟文件, 即不存在文件实体, true(虚拟文件)/false(实体文件)

private String type; // 类型

private String remark; // 备注

private byte[] fileData; //文件数据


/**
* @hibernate.property column="FILEDATA" type="org.springframework.orm.hibernate3.support.BlobByteArrayType" not-null="false" lazy="true"
* @hibernate.meta attribute="field-description" value="文件数据"
*/
public byte[] getFileData() {
return fileData;
}

public void setFileData(byte[] fileData) {
this.fileData = fileData;
}


/**
* @hibernate.id generator-class="native" column="ID"
* @hibernate.meta attribute="field-description" value="主键"
* @hibernate.generator-param name="sequence" value="SEQ_NRMBS"
*/
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

/**
* @hibernate.property not-null="true" length="200" column="BASESHEETID"
* @hibernate.meta attribute="field-description" value="工单ID"
*/
public String getBaseSheetId() {
return baseSheetId;
}

public void setBaseSheetId(String baseSheetId) {
this.baseSheetId = baseSheetId;
}

/**
* @hibernate.property not-null="false" length="500" column="REALNAME"
* @hibernate.meta attribute="field-description" value="原来文件名称"
*/
public String getRealName() {
return realName;
}

public void setRealName(String realName) {
this.realName = realName;
}

/**
* @hibernate.property not-null="false" length="500" column="FILENAME"
* @hibernate.meta attribute="field-description" value="文件名称"
*/
public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}

/**
* @hibernate.property not-null="false" length="200" column="SHEETTYPE"
* @hibernate.meta attribute="field-description" value="工单类型"
*/
public String getSheetType() {
return sheetType;
}

public void setSheetType(String sheetType) {
this.sheetType = sheetType;
}

/**
* @hibernate.property not-null="false" length="19" column="USERID"
* @hibernate.meta attribute="field-description" value="上传人ID"
*/
public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

/**
* @hibernate.property not-null="false" length="200" column="STEPNAME"
* @hibernate.meta attribute="field-description" value="步骤名称"
*/
public String getStepName() {
return stepName;
}

public void setStepName(String stepName) {
this.stepName = stepName;
}

/**
* @hibernate.property not-null="false" length="20" column="USERNAME"
* @hibernate.meta attribute="field-description" value="上传人名称"
*/
public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

/**
* @hibernate.property not-null="false" length="40" column="VIRTUAL"
* @hibernate.meta attribute="field-description" value="虚拟文件"
*/
public String getVirtual() {
return virtual;
}

public void setVirtual(String virtual) {
this.virtual = virtual;
}

/**
* @hibernate.property not-null="false" length="200" column="TYPE"
* @hibernate.meta attribute="field-description" value="类型"
*/
public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

/**
* @hibernate.property not-null="false" length="500" column="REMARK"
* @hibernate.meta attribute="field-description" value="备注"
*/
public String getRemark() {
return remark;
}

public void setRemark(String remark) {
this.remark = remark;
}



}



2.SheetFile.hbm.xml

<?xml version="1.0" encoding="GBK"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
default-lazy="false"
>
<class
name="com.iman.nrms.nrmcs.common.domain.model.sheet.SheetFile"
table="NRMCS_SHEET_FILE"
>
<meta attribute="class-description">上传文件表</meta>

<id
name="id"
column="ID"
type="java.lang.String"
>
<meta attribute="field-description">主键</meta>
<generator class="native">
<param name="sequence">SEQ_NRMBS</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-SheetFile.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="fileData"
type="org.springframework.orm.hibernate3.support.BlobByteArrayType"
update="true"
insert="true"
column="FILEDATA"
not-null="false"
>
<meta attribute="field-description">文件数据</meta>
</property>

<property
name="baseSheetId"
type="java.lang.String"
update="true"
insert="true"
column="BASESHEETID"
length="200"
not-null="true"
>
<meta attribute="field-description">工单ID</meta>
</property>

<property
name="realName"
type="java.lang.String"
update="true"
insert="true"
column="REALNAME"
length="500"
not-null="false"
>
<meta attribute="field-description">原来文件名称</meta>
</property>

<property
name="fileName"
type="java.lang.String"
update="true"
insert="true"
column="FILENAME"
length="500"
not-null="false"
>
<meta attribute="field-description">文件名称</meta>
</property>

<property
name="sheetType"
type="java.lang.String"
update="true"
insert="true"
column="SHEETTYPE"
length="200"
not-null="false"
>
<meta attribute="field-description">工单类型</meta>
</property>

<property
name="userId"
type="java.lang.Long"
update="true"
insert="true"
column="USERID"
length="19"
not-null="false"
>
<meta attribute="field-description">上传人ID</meta>
</property>

<property
name="stepName"
type="java.lang.String"
update="true"
insert="true"
column="STEPNAME"
length="200"
not-null="false"
>
<meta attribute="field-description">步骤名称</meta>
</property>

<property
name="userName"
type="java.lang.String"
update="true"
insert="true"
column="USERNAME"
length="20"
not-null="false"
>
<meta attribute="field-description">上传人名称</meta>
</property>

<property
name="virtual"
type="java.lang.String"
update="true"
insert="true"
column="VIRTUAL"
length="40"
not-null="false"
>
<meta attribute="field-description">虚拟文件</meta>
</property>

<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="TYPE"
length="200"
not-null="false"
>
<meta attribute="field-description">类型</meta>
</property>

<property
name="remark"
type="java.lang.String"
update="true"
insert="true"
column="REMARK"
length="500"
not-null="false"
>
<meta attribute="field-description">备注</meta>
</property>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-SheetFile.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值