concept @Column in category hibernate

appears as: @Column
Java Persistence with Hibernate, Second Edition

This is an excerpt from Manning's book Java Persistence with Hibernate, Second Edition.

Instead of @Basic, most engineers use the more versatile @Column annotation to declare nullability:

@Column(nullable = false)
BigDecimal initialPrice;
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":7}]]"}
!@%STYLE%@!

We’ve now shown you three ways to declare whether a property value is required: with the @Basic annotation, the @Column annotation, and earlier with the Bean Validation @NotNull annotation in section 3.3.2. All have the same effect on the JPA provider: Hibernate does a null check when saving and generates a NOT NULL constraint in the database schema. We recommend the Bean Validation @NotNull annotation so you can manually validate an Item instance and/or have your user interface code in the presentation layer execute validation checks automatically.

The @Column annotation can also override the mapping of the property name to the database column:

@Column(name = "START_PRICE", nullable = false)
BigDecimal initialPrice;
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":7}]]"}
!@%STYLE%@!

The @Column annotation has a few other parameters, most of which control SQL-level details such as catalog and schema names. They’re rarely needed, and we only show them throughout this book when necessary.