Open In App
Related Articles

Spring Data JPA – @Column Annotation

Improve Article
Save Article
Like Article

Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework and making a production-ready application in it takes very little time. In this article, we will discuss how to change the column name in the Spring project using JPA. @Column annotation is used for Adding the column the name in the table of a particular MySQL database.


@Column(name=”DESC”, nullable=false, length=512)

public String getDescription() {  

       return description;  



Name: The name of the column.

length: The column length.

nullable: Whether the database column is nullable.


Step 1: Go to this link. Fill in the details as per the requirements. For this application:

Project: Maven
Language: Java
Spring Boot: 2.5.6
Packaging: JAR
Java: 11
Dependencies: Spring Web,Spring Data JPA, MySql Driver

Click on Generate which will download the starter project.

Step 2: Extract the zip file. Now open a suitable IDE and then go to File > New > Project from existing sources > Mapping and select pom.xml. Click on import changes on prompt and wait for the project to sync as pictorially depicted below as follows:

Step 3: Adding the necessary properties in the file. (mapping is the database name)


Step 4: Create a model folder in the project folder and make a StudentInformation class.



@Table(name = "Student")
public class StudentInformation {
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int rollno;
      @Column(name = "Student_name")
      private String name;
    public int getRollno() { return rollno; }
    public StudentInformation() {}
    public StudentInformation(int rollno, String name)
        this.rollno = rollno; = name;
    public void setRollno(int rollno)
        this.rollno = rollno;
    public String getName() { return name; }
    public void setName(String name) { = name; }

Run the main application:

Database output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 29 Dec, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials