Chinaunix首页 | 论坛 | 博客
  • 博客访问: 593668
  • 博文数量: 805
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 5000
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-17 14:22
文章分类

全部博文(805)

文章存档

2011年(1)

2008年(804)

我的朋友

分类:

2008-10-17 14:26:01

摘要:本文通过一个实例讲述如何通过Spring2+Hibernate3来快捷操作数据库中的Lob字段。
    环境:10g、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;
        }
    }

[1]   

【责编:Ken】

--------------------next---------------------

阅读(265) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~