I am trying to set up a database table using a JpaRepository. I have the following model class:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
@Data
@Entity
@Table
public class MyModel {
@Id
@GeneratedValue
private final int id;
private final String name;
private final String imagePath;
}
When I run my application the table is created just fine. I have manually added a row to the table, yet when I try to look up the row using repository.findById I get the following error:
org.hibernate.InstantiationException: No default constructor for entity: : com.mypackage.mypackage.model.MyModel
I am confused by the 'no default constructor' error. I thought the @Data annotation automatically created a constructor for the class?