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;
        }
    
    }
  • 相关阅读:
    实习记录2
    实习记录1
    silverlight中 Storyboard(动画)的使用,实现球的上下循环移动,左右移动,及旋转功能
    实习记录7(正则表达式)
    SilverLight 控件ListBox中的SelectionChanged事件
    OpenStack collectd的从零安装服务端
    OpenStack 的防火墙规则流程
    OpenStack 的NAT解决办法
    OpenStack 界面开发中的排序问题
    OpenStack 界面开发中response.body的中文编码问题
  • 原文地址:https://www.cnblogs.com/treemanfm/p/3007032.html
Copyright © 2011-2022 走看看