POJO with no Annotations
Exploring lombok annotations by writing a POJO in vanilla Java.
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data // Annotations to simplify writing code (ie constructors, setters)
@NoArgsConstructor
@AllArgsConstructor
@Entity // Annotation to simplify creating an entity, which is a lightweight persistence domain object. Typically, an entity represents a table in a relational database, and each entity instance corresponds to a row in that table.
public class CarBrands {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id; // Unique identifier
@Column(unique=true)
private String brand; // The Joke
private int like; // Store joke likes
private int dislike; // Store joke jeers
}
import javax.persistence.*;
@Entity // Annotation to simplify creating an entity, which is a lightweight persistence domain object. Typically, an entity represents a table in a relational database, and each entity instance corresponds to a row in that table.
public class CarBrands {
public CarBrands() {
this.id = null;
this.brand = "";
this.like = 0;
this.dislike = 0;
}
public CarBrands(Long ID, String Brand, int Like, int Dislike) {
this.id = null;
this.brand = Brand;
this.like = Like;
this.dislike = Dislike;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id; // Unique identifier
@Column(unique=true)
private String brand; // The Joke
private int like; // Store joke likes
private int dislike; // Store joke jeers
// Only have a getter for ID
// Don't need to set since it auto generates
public Long getID() {
return this.id;
}
public String getBrand() {
return this.brand;
}
public void setBrand(String Brand) {
this.brand = Brand;
}
public int getLike() {
return this.like;
}
public void setLike(int Like) {
this.like = Like;
}
public int getDislike() {
return this.dislike;
}
public void setDislike(int Dislike) {
this.dislike = Dislike;
}
}