City.java
@Data
@AllArgsConstructor
@Entity
@Table(name = "cities")
public class City {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private int population = 0;
public City(String name, int population) {
this.name = name;
this.population = population;
}
}
CityRepository.java
@Repository
public interface CityRepository extends CrudRepository<City, Long> {
List<City> findByName(String name);
}