BAEL-2857 Defining a JPA Entity
This commit is contained in:
parent
beccf32be8
commit
8271d0ab5a
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue