![]() |
VOOZH | about |
@Column is part of the Jakarta Persistence API (JPA) and is used within entity classes to specify details about the column that stores a particular field. If no @Column annotation is specified, JPA automatically maps the field name to a column with the same name.
@Column(name = "description", nullable = false, length = 512)
private String description;
Go to Spring Initializr and generate a new project with the following configuration:
Project: Maven
Language: Java
Spring Boot Version: 3.x (Latest LTS)
Dependencies:
Download and extract the project, then open it in your preferred IDE (such as IntelliJ IDEA or Eclipse).
👁 ImageOpen the application.properties file and add the following configuration:
spring.datasource.url=jdbc:mysql://localhost:3306/mapping
spring.datasource.username=root
spring.datasource.password=yourpassword
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
Explanation:
Create a new package com.example.model and add the entity class
StudentInformation.java:
Run the Spring Boot main class (the one annotated with @SpringBootApplication).
👁 ImageSpring Boot will automatically connect to the database and generate a table named student with the specified column properties.
Use the following SQL command in MySQL to inspect the created table structure:
DESC student;
Expected Output:
👁 Image