一:Hibernate3.X實現基于CLOB字段類型的注解方式的例子:下面直接上代碼:
二:UserInfo.java
package cn.gov.csrc.cms.model;import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;import oracle.sql.CLOB;/**
* File: UserInfo.java
* Author: admin
* Version: 1.0
* Date: 2014/08/13
* Modify:
* Description: 系統用戶表
* Copyright: sinodata
*/
@Entity
@Table(name = "tb_cms_user")
public class UserInfo {private Integer userId;// IDprivate String userName;// 登錄名private String passWd;// 登錄密碼private String realName;// 用戶姓名private String phone;// 電話private String dept;// 部門private String post;// 崗位private CLOB fieldNames;// 存放xml文本文件的字段@Id@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")@SequenceGenerator(name = "SEQ_STORE", sequenceName = "USER_SEQ", allocationSize = 1)public Integer getUserId() {return userId;}public void setUserId(Integer userId) {this.userId = userId;}@Column(name = "USERNAME", nullable = false, length = 30)public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}@Column(name = "PASSWD", nullable = false, length = 100)public String getPassWd() {return passWd;}public void setPassWd(String passWd) {this.passWd = passWd;}@Column(name = "REALNAME", length = 10)public String getRealName() {return realName;}public void setRealName(String realName) {this.realName = realName;}@Column(name = "PHONE", length = 15)public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}@Column(name = "DEPT", length = 10)public String getDept() {return dept;}public void setDept(String dept) {this.dept = dept;}@Column(name = "POST", length = 10)public String getPost() {return post;}public void setPost(String post) {this.post = post;}@Lob @Basic(fetch = FetchType.EAGER) @Column(name="FIELDNAMES", columnDefinition="CLOB", nullable=true)public CLOB getFieldNames() {return fieldNames;}public void setFieldNames(CLOB fieldNames) {this.fieldNames = fieldNames;}}
三:Oracle中直接通過sql插入CLOB字段類型的數據:
/* Formatted on 2014/8/19 15:45:29 (QP5 v5.115.810.9015) */
INSERT INTO TB_CMS_USER (USERID,DEPT,PASSWD,PHONE,POST,REALNAME,USERNAME,FIELDNAMES)VALUES (1,'開發支持部','123456789','18611966723','Java工程師','工程師','zhaoxinguo','<?xml version="1.0" encoding="UTF-8"?>
<ASUPDATA><MSG> <META> <SNDR>DC</SNDR> <DTTM>20140714001122</DTTM> <TYPE>FLOP</TYPE> <STYP>FGIS</STYP> </META> <FLOP> <FFID>CZ-CZ3726-D-14JUL142220-D</FFID> <CHDT>29</CHDT> </FLOP></MSG>
</ASUPDATA>');