我有另一个关于JPA的问题.如果我想将它存储在我的数据库中,是否有必要使用@Column注释每个成员变量?或者是否可以通过某些成员变量(在这些示例中为"timestamp"字段)将其遗漏,并且此字段将在每个可能的方案中存储在数据库中:
@Entity
@Table(name = "usercontent")
public class UserContentEntity implements Persistable<Long> {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "description")
private String contentdescription;
@Column(name = "name")
private String contentname;
@Column(name = "bytes")
@Lob
private byte[] contentbytes;
@Column
private String creator;
private Date timestamp;
// get- and set methods
}
Run Code Online (Sandbox Code Playgroud)
当使用注释@Column是绝对必要的吗?
非常感谢Maik
Nei*_*ton 26
不,它不是"必要的",除非你想覆盖默认的列命名,或默认的数据存储列类型等.只是把@Column无论如何都不做
| 归档时间: |
|
| 查看次数: |
7996 次 |
| 最近记录: |