BAEL-2857 Defining a JPA Entity

This commit is contained in:
Vivek 2019-04-13 14:37:15 +05:30
parent beccf32be8
commit 8271d0ab5a
2 changed files with 10 additions and 2 deletions

View File

@ -17,7 +17,7 @@ import javax.persistence.Transient;
import com.baeldung.util.Gender;
@Entity
@Table(name="STUD_NAME")
@Table(name="STUD")
public class Student {
@Id

View File

@ -2,6 +2,8 @@ package com.baeldung.jpa.entity;
import static org.junit.Assert.assertEquals;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
@ -75,9 +77,15 @@ public class StudentEntityIntegrationTest {
Student student = new Student();
student.setAge(20); // the 'age' field has been annotated with @Transient
student.setName("John");
student.setBirthDate(new Date());
Date date = getDate();
student.setBirthDate(date);
student.setGender(Gender.MALE);
return student;
}
private Date getDate() {
LocalDate localDate = LocalDate.of(2008, 7, 20);
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
}