Hibernate+Spring搞定Clob、Blob的存取

来源:51cto博客 作者:熔岩 2008-05-12 出处:pcdog.com

  • hibernate
  • office
  • oracle
  • spring
  • .net
  • 下一页1234

        摘要:本文通过一个实例讲述如何通过Spring2+Hibernate3来快捷操作数据库中的Lob字段。
        环境:Oracle10g、Srping2、Hibernate3、JUint4

        说明:由于时间紧迫,没有详细写出思路。运行一下例子就明白了。


        一、创建实体并添加Xdoclet的Hibernate标签

        /**
         * @author leizhimin
         * @hibernate.mapping default-lazy="false"
         * @hibernate.meta attribute="class-description" value="工作日志"
         * @hibernate.class table="rc_gzrz"
         */
        public class WorkNote {
            private Long id;                    //标识
            private Date workDate;             //日期
            private String weather;             //天气
            private String content;             //日志内容(Clob)
            private String state;               //日志状态
            private Long orgId;                 //机构id
            private Long userId;                //用户id
            private Date createDate;            //创建日期
            private byte[] image;               //图片

            public static final String WORKNOTE_BLANK = "00";         //未填写
            public static final String WORKNOTE_FULL = "11";          //已填写

            /**
             * @hibernate.id generator-class="sequence" column="BS"
             * @hibernate.meta attribute="field-description" value="标识"
             * @hibernate.generator-param name="sequence" value="SEQ_GW"
             */
            public Long getId() {
                return id;
            }

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

            /**
             * @hibernate.property column="workDate" not-null="false" type="timestamp"
             * @hibernate.meta attribute="field-description" value="工作日期"
             */

            public Date getWorkDate() {
                return workDate;
            }

            public void setWorkDate(Date workDate) {
                this.workDate = workDate;
            }

            /**
             * @hibernate.property column="weather" not-null="false" length="24"
             * @hibernate.meta attribute="field-description" value="天气"
             */
            public String getWeather() {
                return weather;
            }

            public void setWeather(String weather) {
                this.weather = weather;
            }

            /**
             * @hibernate.property column="content" not-null="false" type="text"
             * @hibernate.meta attribute="field-description" value="内容"
             */
            public String getContent() {
                return content;
            }

            public void setContent(String content) {
                this.content = content;
            }

            /**
             * @hibernate.property column="state" not-null="false" length="2"
             * @hibernate.meta attribute="field-description" value="状态"
             */
            public String getState() {
                return state;
            }

            public void setState(String state) {
                this.state = state;
            }

            /**
             * @hibernate.property column="orgId" type="long"
             * @hibernate.meta attribute="field-description" value="机构id"
             */
            public Long getOrgId() {
                return orgId;
            }

            public void setOrgId(Long orgId) {
                this.orgId = orgId;
            }

            /**
             * @hibernate.property column="userId" type="long"
             * @hibernate.meta attribute="field-description" value="用户id"
             */
            public Long getUserId() {
                return userId;
            }

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

            /**
             * @hibernate.property column="createDate" not-null="false" type="timestamp"
             * @hibernate.meta attribute="field-description" value="创建日期"
             */
            public Date getCreateDate() {
                return createDate;
            }

            public void setCreateDate(Date createDate) {
                this.createDate = createDate;
            }

            /**
             * @hibernate.property column="image" type="blob" not-null="false"
             * @hibernate.meta attribute="field-description" value="图片"
             */
            public byte[] getImage() {
                return image;
            }

            public void setImage(byte[] image) {
                this.image = image;
            }
        }


    更多内容请看PCdog.com--Spring开发技术篇Hibernate相关文章专题
    下一页1234
    上一篇:Java技术—IDEA的快捷键介绍
    下一篇:Java开发技术是优秀的