The error
java: constructor Restaurant() is already defined in class
com.example.order_system.domain.Restaurant
appear when I add this class and run the program
@Entity
@NoArgsConstructor
@RequiredArgsConstructor
@Getter
@Setter
@ToString
public class Restaurant {
@Id
@GeneratedValue
private long id;
@NotEmpty(message = "The restaurant must have a name")
private String name;
@NotEmpty(message = "Please add a description for this restaurant")
private String description;
@NotEmpty(message = "The restaurant must have a location")
private String location;
@OneToMany(mappedBy = "restaurant", fetch = FetchType.EAGER)
private List<ContactDetails> contactDetails = new ArrayList<>();
}
@RequiredArgsConstructorchecks for uninitializedfinaland@NotNullfields, not for@NotEmptyones, so it's probably just generating another no-arguments constructor.@Dataannotation anyway. It combines@RequiredArgsConstructor,@Getter,@Setter,@ToStringand additionally@EqualsAndHashCodewhich is always a good idea for entities.