English 中文(简体)
org.hibernate.id.IdentifierGenerationException: ids for this category must be Manually assigned before calls Save()
原标题:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()

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

最佳回答

您在模块Infos收集上都有一栏,因此,如果你节省安装信息,就会设法拯救所有相关模块Infos。 你们需要确保,在保留安装Info物体之前,安装单元信息器。

@OneToMany(fetch = FetchType.EAGER, mappedBy = "installationInfo", 
   targetEntity=ModuleInfo.class, cascade={CascadeType.ALL})    //targerEntity is added by Isuru
public Set<ModuleInfo> getModuleInfos() {
    return this.moduleInfos;
}
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签