- Developing Middleware in Java EE 8
- Abdalla Mahmoud
- 199字
- 2021-07-23 19:24:37
Column mapping
By default, all fields (or getter methods, according to @Id place) are mapped as columns in the containing table, with a default name matching the field (or getter) name, and a default type matching its Java type, if you need to customize how a column is mapped in the database, as in the following code snippet:
@Entity public class Movie { @Column(name = "movie_title") private String title; .... }
In the previous example, we have customized the name of the title field to movie_title. Moreover, the previous example maps by default to the database type VARCHAR. As you know, VARCHAR types have a length. The default length of a VARCHAR field in JPA is 255, but you can customize this value by using the length attribute:
@Entity public class Movie { @Column(name = "movie_title", length=100) private String title; .... }
If you have a text type available in your database, you can also modify the default type by using the columnDefinition attribute:
@Entity public class Movie { @Column(name = "movie_title", columnDefinition = "text") private String title; .... }
Other attributes are available for the customization of table columns, as shown in the following table:

- TensorFlow Lite移動端深度學習
- Kubernetes實戰
- Instant Apache Stanbol
- JavaScript+jQuery網頁特效設計任務驅動教程(第2版)
- 精通網絡視頻核心開發技術
- Clojure for Java Developers
- Struts 2.x權威指南
- 區塊鏈架構之美:從比特幣、以太坊、超級賬本看區塊鏈架構設計
- Tableau Desktop可視化高級應用
- DB2SQL性能調優秘笈
- Swift High Performance
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- Spring Web Services 2 Cookbook
- 零基礎C語言學習筆記
- Learning Dynamics NAV Patterns