I have entityclass ProjectData. In this class I have UserData entity object. I use @JoinColumn annotation to get userData when I get ProjectData- it work properly. But if I create new ProjectData I don't know how to save userDataId to PRJ_USER_PM_ID column;
In table PROJECT I have id of user data. I try with additional attrbute projectUserid, but it seems to me it is not good solution.
@Entity
@Table(name="PROJECT")
public class ProjectData extends AbstractData {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "PRJ_USER_PM_ID", referencedColumnName = "USR_ID", insertable = false, updatable = false )
UserData user;
/*@Column(name = "PRJ_USER_PM_ID")
Long projectUserid; */
}
Create a userData with required ID if you dont have it, and just set it to projectData:
projectData.setUserData (userData);
And then save projectData.
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.