i have a spring boot and hibernate based project that contains a simple schedule(pojo) class and an entity class to save in mysql using hibernate.
Now i want to create a field in tutorAvailableSchedules entity which is an array of schedule type. when i try the below code it gives me the error.
availableSchedule.class ->pojo
package fG.Model;
import java.util.Arrays;
public class availablitySchedule {
String startTime;
String endTime;
String days[];
}
TutorAvailablitySchedules.class ->Entity
package fG.Entity;
import fG.Model.availablitySchedule;
@Entity
public class TutorAvailablitySchedules {
@Id
Integer tid;
String fullName;
availablitySchedule[] availableSchedules;
String currentSchedule;
String availablityStatus;
}
error i get:
Could not determine type for: fG.Model.availablitySchedule, at table: tutor_availablity_schedules, for columns: [org.hibernate.mapping.Column(available_schedules)]
I will sketch you a possible solution. It may need some refinement, depending on how you want to model the relationship of your entities.
AvailablitySchedule
as @Entity
such that it reflects a table. As a consequence you will have to think about an id.AvailablitySchedule[] availableSchedules
in class TutorAvailablitySchedules
to List<AvailablitySchedule> availableSchedules
@OneToMany
relationship between TutorAvailablitySchedules
and AvailablitySchedule
by annotating field List<AvailablitySchedule> availableSchedules
in TutorAvailablitySchedules
with @OneToMany
String[] days;
to List<String> days;
in class AvailablitySchedule
List<String> days;
with eg @ElementCollection
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.