在我的Java程序枚举中是这样的..
public enum WeekdayType {
MONDAY(Calendar.MONDAY), TUESDAY(Calendar.TUESDAY), WEDNESDAY(
Calendar.WEDNESDAY), THURSDAY(Calendar.THURSDAY), FRIDAY(
Calendar.FRIDAY), SATURDAY(Calendar.SATURDAY), SUNDAY(
Calendar.SUNDAY);
private int day;
private WeekdayType(int day) {
this.day = day;
}
public int getDay() {
return day;
}
}
我的 Hibernate bean 像这样定义TimetableVO.java
@Column(name="REPEAT_DAYS")
@Enumerated(EnumType.STRING)
private WeekdayType repeatDays;// And Setter and Getters....
在我的服务课上,我正在这样做..
String totalDays="MONDAY,SUNDAY,FRIDAY,SATURDAY"
public void createEvent(TimetableVO timetableVO) {
WeekdayType weekday = null;
for (String day : totalDays.split(",")) {
weekday = WeekdayType.valueOf(day);
}
timetableVO.setRepeatDays(weekday);
......
......
......
entityManager.persist(timetableVO);
}
但问题是在数据库列中仅添加最后一个值......这意味着它会覆盖以前的值
例如:以上字符串SATURDAY
仅插入数据库,但我想插入所有值,如MONDAY,SUNDAY,FRIDAY,SATURDAY
...给我建议..