Column Annotations are absolutely necessary in JPA?

I have one more question regarding JPA. Do I need to annotate each @Column member variable if I want to store it in my database? Or you can leave it with some member variables (in this example, the "timestamp" field), and this field will be stored in the database in every possible scenario:

@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 } 

And when do you absolutely need to use the @Column annotation?

Thanks a lot Maik

+8
java jpa
source share
1 answer

Not. it is not "necessary" if you do not want to override the default column name or the default data warehouse column type, etc. And just posting @Column doesn't do anything as such anyway

+14
source share

All Articles