如何使用基于Column注解的columnDefinition

发布时间:2021-10-25 10:10:09 作者:iii
来源:亿速云 阅读:171

本篇内容介绍了“如何使用基于Column注解的columnDefinition”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

目录

Column注解的columnDefinition使用

columnDefinition属性表示创建表时,该字段创建的SQL语句,一般用于通过Entity生成表定义时使用,如果数据库中表已经建好,该属性没有必要使用

1、指定字段类型、长度、是否允许null、是否唯一、默认值

/** 仓库编号 */
@Column(name = "code",columnDefinition = "Varchar(100) not null default'' unique")
private String code;

2、需要特殊指定字段类型的情况

@Column(name = "remark",columnDefinition="text")
private String remark;
@Column(name = "salary", columnDefinition = "decimal(5,2)")
private BigDecimal salary;
@Column(name="birthday",columnDefinition="date")
private Date birthday;
@Column(name="createTime",columnDefinition="datetime")
private Date createTime;

@Column注解的各个字段的解释

查看源码:

@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Column {
    String name() default "";
    boolean unique() default false;
    boolean nullable() default true;
    boolean insertable() default true;
    boolean updatable() default true;
    String columnDefinition() default "";
    String table() default "";
    int length() default 255;
    int precision() default 0;
    int scale() default 0;
}

解释:

“如何使用基于Column注解的columnDefinition”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

推荐阅读:
  1. 怎么使用column-gap属性
  2. 如何使用php array_column()函数

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

column

上一篇:Linux命令行字符形状工具boxes怎么用

下一篇:Python爬虫经常会被封的原因是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》