I got the above error though i have set the ID manually, Im not using auto generated key here. when i set the key and pass the object to
entityManager.persist(obj);
it gives the above error. any help... plz
thanks
这是安装Info级,在安装Info物体时,我发现上述错误。 完全错误是
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): se.cambio.cimonitor.jpa.table.ModuleInfo
因此,我附上了模块Info课程。
package se.cambio.cimonitor.jpa.table;
@Entity
@Table(name = "InstallationInfo", catalog="CI_Monitor", schema="dbo")
public class InstallationInfo implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String installationId;
private String timestamp;
private Module moduleByParentId;
private Environment environmentByEnvironmentClientId;
private Environment environmentByEnvironmentServerId;
private Module moduleByBaseLineId;
private String machineName;
private String status;
private String teamName;
private Set<ModuleInfo> moduleInfos = new HashSet<ModuleInfo>(0);
public InstallationInfo() {
iii
public InstallationInfo(String installationId) {
this.installationId = installationId;
iii
public InstallationInfo(String installationId,
Module moduleByParentId,
Environment environmentByEnvironmentClientId,
Environment environmentByEnvironmentServerId,
Module moduleByBaseLineId, String machineName,
String status, String teamName,
Set<ModuleInfo> moduleInfos) {
this.installationId = installationId;
this.moduleByParentId = moduleByParentId;
this.environmentByEnvironmentClientId = environmentByEnvironmentClientId;
this.environmentByEnvironmentServerId = environmentByEnvironmentServerId;
this.moduleByBaseLineId = moduleByBaseLineId;
this.machineName = machineName;
this.status = status;
this.teamName = teamName;
this.moduleInfos = moduleInfos;
iii
/*@TableGenerator(name="InstlIds", table="InstlPkTb", pkColumnName="InstlId", pkColumnValue="InstlIdVal", allocationSize=1, catalog="CI_Monitor", schema="dbo")
@GeneratedValue(strategy=GenerationType.TABLE, generator="InstlIds")*/
@Id
@Column(name = "InstallationId", unique = true, nullable = false, insertable = true, updatable = true)
public String getInstallationId() {
return this.installationId;
iii
public void setInstallationId(String installationId) {
this.installationId = installationId;
iii
//@Version This is a bug
@Column(name = "Timestamp")
public String getTimestamp() {
return this.timestamp;
iii
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ParentId")
public Module getModuleByParentId() {
return this.moduleByParentId;
iii
public void setModuleByParentId(Module moduleByParentId) {
this.moduleByParentId = moduleByParentId;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "EnvironmentClientId")
public Environment getEnvironmentByEnvironmentClientId() {
return this.environmentByEnvironmentClientId;
iii
public void setEnvironmentByEnvironmentClientId(
Environment environmentByEnvironmentClientId) {
this.environmentByEnvironmentClientId = environmentByEnvironmentClientId;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "EnvironmentServerId")
public Environment getEnvironmentByEnvironmentServerId() {
return this.environmentByEnvironmentServerId;
iii
public void setEnvironmentByEnvironmentServerId(
Environment environmentByEnvironmentServerId) {
this.environmentByEnvironmentServerId = environmentByEnvironmentServerId;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "BaseLineId")
public Module getModuleByBaseLineId() {
return this.moduleByBaseLineId;
iii
public void setModuleByBaseLineId(Module moduleByBaseLineId) {
this.moduleByBaseLineId = moduleByBaseLineId;
iii
@Column(name = "MachineName")
public String getMachineName() {
return this.machineName;
iii
public void setMachineName(String machineName) {
this.machineName = machineName;
iii
@Column(name = "Status")
public String getStatus() {
return this.status;
iii
public void setStatus(String status) {
this.status = status;
iii
@Column(name = "TeamName")
public String getTeamName() {
return teamName;
iii
public void setTeamName(String teamName) {
this.teamName = teamName;
iii
@OneToMany(fetch = FetchType.EAGER, mappedBy = "installationInfo", targetEntity=ModuleInfo.class, cascade={CascadeType.ALLiii) //targerEntity is added by Isuru
public Set<ModuleInfo> getModuleInfos() {
return this.moduleInfos;
iii
public void setModuleInfos(Set<ModuleInfo> moduleInfos) {
this.moduleInfos = moduleInfos;
iii
iii
package se.cambio.cimonitor.jpa.table;
@Entity
@Table(name = "ModuleInfo", catalog="CI_Monitor", schema="dbo")
public class ModuleInfo implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private ModuleInfoId id;
private InstallationInfo installationInfo;
private Module moduleByModuleId;
private Module moduleByParentId;
private Module moduleByBaseLineId;
private String buildNo;
private String svnRevision;
public ModuleInfo() {
iii
public ModuleInfo(ModuleInfoId id, InstallationInfo installationInfo,
Module moduleByModuleId) {
this.id = id;
this.installationInfo = installationInfo;
this.moduleByModuleId = moduleByModuleId;
iii
public ModuleInfo(ModuleInfoId id, InstallationInfo installationInfo,
Module moduleByModuleId, Module moduleByParentId,
Module moduleByBaseLineId, String buildNo,
String svnRevision) {
this.id = id;
this.installationInfo = installationInfo;
this.moduleByModuleId = moduleByModuleId;
this.moduleByParentId = moduleByParentId;
this.moduleByBaseLineId = moduleByBaseLineId;
this.buildNo = buildNo;
this.svnRevision = svnRevision;
iii
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "moduleId", column = @Column(name = "ModuleId", nullable = false)),
@AttributeOverride(name = "installationId", column = @Column(name = "InstallationId", nullable = false)) iii)
public ModuleInfoId getId() {
return this.id;
iii
public void setId(ModuleInfoId id) {
this.id = id;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "InstallationId", nullable = false, insertable = false, updatable = false, unique = true)
public InstallationInfo getInstallationInfo() {
return this.installationInfo;
iii
public void setInstallationInfo(InstallationInfo installationInfo) {
this.installationInfo = installationInfo;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ModuleId", nullable = false, insertable = false, updatable = false)
public Module getModuleByModuleId() {
return this.moduleByModuleId;
iii
public void setModuleByModuleId(Module moduleByModuleId) {
this.moduleByModuleId = moduleByModuleId;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ParentId")
public Module getModuleByParentId() {
return this.moduleByParentId;
iii
public void setModuleByParentId(Module moduleByParentId) {
this.moduleByParentId = moduleByParentId;
iii
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "BaseLineId")
public Module getModuleByBaseLineId() {
return this.moduleByBaseLineId;
iii
public void setModuleByBaseLineId(Module moduleByBaseLineId) {
this.moduleByBaseLineId = moduleByBaseLineId;
iii
@Column(name = "BuildNo")
public String getBuildNo() {
return this.buildNo;
iii
public void setBuildNo(String buildNo) {
this.buildNo = buildNo;
iii
@Column(name = "SvnRevision")
public String getSvnRevision() {
return this.svnRevision;
iii
public void setSvnRevision(String svnRevision) {
this.svnRevision = svnRevision;
iii
iii