zoukankan      html  css  js  c++  java
  • Hibernate3.x 中BLOB、CLOB 注解配置写法

    在hibernate Annotation中,实体BLOB、CLOB类型的注解与普通的实体属性有些不同,具体操作如下:

    import javax.persistence.Basic;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.Id;
    import javax.persistence.Lob;
    import javax.persistence.Table;
    
    @Entity
    @Table(name = "T_USER", schema = "TRS_CMS")
    public class TUser implements java.io.Serializable {
    
        // Fields
    
        private Long id;
        private String name;
        
        //CLOB类型,类型声明为String
        private String introduction;
        //BLOB类型,类型声明为byte[]:
        private byte[] icon;
    
        // Constructors
    
        /** default constructor */
        public TUser() {
        }
    
        // Property accessors
        @Id
        @Column(name = "ID", unique = true, nullable = false, precision = 22, scale = 0)
        public Long getId() {
            return this.id;
        }
    
        public void setId(Long id) {
            this.id = id;
        }
    
        @Column(name = "NAME", length = 40)
        public String getName() {
            return this.name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
        
        
        //--============== 华丽的分割线================================
        @Lob  
        @Basic(fetch = FetchType.EAGER)
        @Column(name = "INTRODUCTION", columnDefinition = "CLOB",nullable=true)
        public String getIntroduction() {
            return this.introduction;
        }
    
        public void setIntroduction(String introduction) {
            this.introduction = introduction;
        }
        
        //--============== 华丽的分割线================================
        @Lob  
        @Basic(fetch = FetchType.LAZY)
        @Column(name = "ICON", columnDefinition = "BLOB",nullable=true)
        public byte[] getIcon() {
            return this.icon;
        }
    
        public void setIcon(byte[] icon) {
            this.icon = icon;
        }
    
    }
  • 相关阅读:
    界面布美观布局
    登陆界面验证码设置
    很好的JAVESRIPT控件
    c#导入EXCEL数据
    微软:系列课程 >Silverlight for Windows Phone 开发系列课程
    JavaScript动态网页制作宝库
    Silverlight经典教程书籍汇总
    SQL删除表中有重复的记录
    Javascript鼠标事件
    Android系统架构(转)
  • 原文地址:https://www.cnblogs.com/treemanfm/p/3007032.html
Copyright © 2011-2022 走看看