在我的Hibernate Pojo课程中,我正在使用这样的...
@Entity
@Table(name="EC_TIMETABLE")
public class TimetableVO{
@ManyToOne
@JoinColumn(name="SKILLSET_ID", insertable=false, updatable=false)
private SkillsetVO skillset;
...
...
}
和另一个豆
@Entity
@Table(name="EC_SKILLSET")
public class SkillsetVO{
@ManyToOne
@JoinColumn(name="USER_ID", insertable=false, updatable=false)
private UserVO user;
@ManyToOne
@JoinColumn(name="COURSE_ID", insertable=false, updatable=false)
private CourseVO course;
}
我的用户Bean ..
@Entity
@Table(name = "EC_USER")
public class UserVO extends AbstractVO {
@OneToMany(mappedBy = "user", fetch = FetchType.EAGER)
private Set<SkillsetVO> skillset;
}
在我的Service类中,我正在插入bean ..
@Transactional
public void createEvent(TimetableVO timetableVO) throws DataAccessException {
System.out.println(timetableVO.getSkillset().getId());//Hear id is P.K in SkillSetVO
entityManager.persist(timetableVO);
}
听取输出声明打印"S1"
但在数据库中显示NULL
...
他们将任何错误的映射设置为Bean类吗?
答案 0 :(得分:3)
@ManyToOne
@JoinColumn(name="SKILLSET_ID", insertable=false, updatable=false)
private SkillsetVO skillset;
尝试删除insertable=false