I have an Employer class looking like this:
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
public class Employer {
private @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employer")
private List<Offer> offerList = new ArrayList<>();
private String name;
private String location;
private String description;
private int companySize;
public Employer(String name, String location, String description) {
this.name = name;
this.location = location;
this.description = description;
}
}
Sending GET request on localhost:8080/employers gets me:
ERROR 6154 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: No default constructor for entity: : com.krdkta.internship_for_you.model.Employer; nested exception is org.hibernate.InstantiationException: No default constructor for entity: : com.krdkta.internship_for_you.model.Employer] with root cause
Even though there's clearly an Lombok Annotation that defines this no argument constructor, but still I get this error. Is there any contraindications to using Lombok with Hibernate :)?