相关疑难解决方法(0)

javax.persistence @Column上的length字段是否定义了max?

我有这个代码:

public class Item { 
    @Column(name = "serialNo", length = 12)
    public String getSerialNo() {
        return this.serialNo;
    }

    public void setSerialNo(String serialNo) {
        this.serialNo = serialNo;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,数据库模式将列定义为长度为13.当通过以下方式检索项时:

List<Item> items = getEntityManager().createNamedQuery(SQL).getResultList();
Run Code Online (Sandbox Code Playgroud)

具有数据serialNo等于字符13(因为分贝表模式允许13)仍然被显示为13,不会被截断.@Column length当时有什么用?

java annotations hibernate jpa entity-model

6
推荐指数
1
解决办法
6287
查看次数

标签 统计

annotations ×1

entity-model ×1

hibernate ×1

java ×1

jpa ×1