Consider a Spring Boot entity with a field annotated as @Column(name = "user_email"). What does this annotation do?
public class User { @Column(name = "user_email") private String email; }
Think about how Java fields connect to database columns.
The @Column(name = "user_email") annotation tells Spring Boot to map the Java field email to the database column named user_email. It does not rename the Java field or change data values.
Which option correctly uses @Column to make a database column NOT NULL?
public class Product {
@Column(??? )
private String name;
}Check the exact attribute name for nullability in @Column.
The correct attribute to specify that a column cannot be null is nullable = false. Other options are invalid attributes.
Given the entity field below, why will the application fail at runtime?
public class Order { @Column(name = "order_date", length = 10) private LocalDate date; }
Consider which @Column attributes apply to which data types.
The 'length' attribute applies only to string-based columns. Using it on a LocalDate field causes a runtime error because the database column type does not support length.
Given the entity below, what is the exact database column name for the field userName?
public class Account { @Column(name = "user_name") private String userName; }
Look at the name attribute inside @Column.
The name attribute explicitly sets the database column name to 'user_name'. The Java field name does not affect the column name when this attribute is present.
In a Spring Boot JPA entity, if a field has no @Column annotation, what is the default behavior for database column mapping?
public class Customer {
private String address;
}Think about default JPA mapping conventions.
If @Column is omitted, JPA maps the field to a database column with the same name as the field, applying default column settings.