return clobContent;
}
public void setClobContent(String clobContent) {
this.clobContent = clobContent;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBlobName() {
return blobName;
}
public void setBlobName(String blobName) {
this.blobName = blobName;
}
public String getClobName() {
return clobName;
}
public void setClobName(String clobName) {
this.clobName = clobName;
}
}
将对象的映射文件中主健字段元素的内置生成器指定为sequence,并与达梦数据库重的内置序列(sequence)关联,最后指定CLOB类型的属性为"string"类型,BLOB类型的属性为"binary"类型:
<?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.dm.lobtest.vo.TestLob" table="TESTLOB">
<id name="id" column="ID" type="int">
<generator class="sequence">
<param name="sequence">SEQ_TESTLOB_ID</param>
</generator>
</id>
<property name="title" column="TITLE" type="string" />
<property name="clobName" column="CLOBNAME" type="string" />
<property name="blobName" column="BLOBNAME" type="string" />
<property name="clobContent" column="CLOBCONTENT" type="string" />
<property name="blobContent" column="BLOBCONTENT" type="binary" />
</class>
</hibernate-mapping>
利用Hibernate储存大对象到达梦数据库(3)
时间:2011-03-07 IT专家网 徐欣
完成以上这些操作后我们可以开始编写上传文件页面和处理上传文件的业务逻辑了,
定义上传文件页面:
<form name="myTestLobFrm" method="post" enctype="multipart/form-data" action="/LobTest/testlob.do?method=save">
<table align="center">
<tr>
<td colspan="2">
<b>达梦数据库CLOB和BLOB数据类型在Hibernate下使用的示例</b>
</td>
</tr>
<tr>
<td>标题:</td>
<td>
<input type="text" name="title" size="81">
</td>
</tr>
<tr>
<td>文件内容:</td>
<td>
<textarea rows="20" cols="80" name="clobTest" ></textarea>
</td>
</tr>
<tr>
<td>附件:</td>
<td>
<input type="file" name="blobTest" size="71">
</td>
</tr>
<tr>
<td colspan=&quo
|