0
0
Spring Bootframework~5 mins

Column mapping with @Column in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the @Column annotation in Spring Boot?
The @Column annotation maps a Java class field to a specific column in a database table. It helps customize column properties like name, length, and nullability.
Click to reveal answer
beginner
How do you specify a custom column name using @Column?
Use the 'name' attribute inside @Column, for example: @Column(name = "user_email") maps the field to the 'user_email' column in the table.
Click to reveal answer
beginner
What does setting nullable = false in @Column do?
It makes the database column NOT NULL, meaning the column must always have a value and cannot be left empty.
Click to reveal answer
beginner
Can @Column control the length of a String column? How?
Yes, by setting the 'length' attribute, e.g., @Column(length = 100) limits the string column to 100 characters.
Click to reveal answer
beginner
What happens if you omit the @Column annotation on a field?
Spring Boot uses default mapping: the field name becomes the column name, and default settings apply for length, nullability, etc.
Click to reveal answer
Which attribute of @Column sets the database column name?
Aname
Blength
Cnullable
Dunique
What does @Column(nullable = false) enforce?
AColumn length is unlimited
BColumn can be empty
CColumn is unique
DColumn must have a value
How do you limit a String column to 50 characters using @Column?
A@Column(length = 50)
B@Column(size = 50)
C@Column(max = 50)
D@Column(limit = 50)
If you do not use @Column on a field, what happens?
AField is ignored
BError occurs
CDefault column mapping applies
DField becomes primary key
Which @Column attribute ensures column values are unique?
Aname
Bunique
Clength
Dnullable
Explain how to use @Column to customize a database column in Spring Boot.
Think about how you control column name, size, and whether it can be empty.
You got /4 concepts.
    Describe what happens if you omit the @Column annotation on a field in a Spring Boot entity.
    Consider the default mapping rules Spring Boot applies.
    You got /3 concepts.