TheOnlyTails
01/15/2021, 10:28 PM@Entity
@Table
class Student(
@Id
@SequenceGenerator(name = "student_sequence", sequenceName = "student_sequence", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "student_sequence")
val id: Long,
val name: String,
val email: String,
val dateOfBirth: LocalDate,
val age: Int = LocalDate.now().year - dateOfBirth.year
)
I'm trying to access it in this class, and I think I'm supposed to leave out the id
so it can get filled in automatically, but it's not working. Here is where I try to create it:
@Configuration
class StudentConfig {
@Bean
fun commandLineRunner(repository: StudentRepository): CommandLineRunner {
return CommandLineRunner{
val theonlytails = Student(
"TheOnlyTails",
"<mailto:shacharzidon@gmail.com|shacharzidon@gmail.com>",
LocalDate.of(2000, Month.JANUARY, 1)
)
repository.save(theonlytails)
}
}
}
What is going on here?