You are currently viewing Spring Boot Masterclass – Create an entity class for Expense 05

Spring Boot Masterclass – Create an entity class for Expense 05

Hello, in this post we will create an entity class for Expense. let’s begin. Create a class Expense under src/main/java/in/bushansirgur/expenseyoutube/model package

We will use Lombok annotations @Setter, @Getter to override the setters and getters and @ToString to override the toString() method.

Expense.java




package in.bushansirgur.expenseyoutube.model;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Entity
@Table(name="tbl_expenses")
@Setter
@Getter
@ToString
public class Expense {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@Column(name="description")
	private String expensename;
	
	private BigDecimal amount;
	
	private String note;
	
	private Long createdAt;
}

Thanks
Bushan SC

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply