Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface PetMapper {

Collection<PetDto> toPetsDto(Collection<Pet> pets);

Collection<Pet> toPets(Collection<PetDto> pets);
Collection<Pet> toPets(Collection<PetDto> pets);

@Mapping(source = "ownerId", target = "owner.id")
Pet toPet(PetDto petDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
package org.springframework.samples.petclinic.model;

import jakarta.persistence.*;
import jakarta.validation.constraints.PastOrPresent;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.util.*;

Expand All @@ -32,6 +35,9 @@
public class Pet extends NamedEntity {

@Column(name = "birth_date", columnDefinition = "DATE")
@Temporal(TemporalType.DATE)
@DateTimeFormat(pattern = "yyy-MM-dd")
@PastOrPresent(message = "Birth Date cannot be in the future")
private LocalDate birthDate;

@ManyToOne(cascade = CascadeType.ALL)
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application-mysql.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# database init, supports mysql too
spring.sql.init.platform=mysql
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic}
spring.datasource.username=${MYSQL_USER:petclinic}
spring.datasource.password=${MYSQL_PASS:petclinic}
spring.datasource.username=root
spring.datasource.password=gitesh
# SQL is written to be idempotent so this is safe
spring.sql.init.mode=always