Oct 29, 2015 2:29:48 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/globeconnect] threw exception [Request processing failed; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.globetouch.business.entities.DummyData] with root cause
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.globetouch.business.entities.DummyData
@Entity
@Table(name="DUMMY_DATA")
public class DummyData {
@Id
@Column(name="ICCID")
private String ICCID;
@Column(name="IMSI")
private String IMSI;
create table DUMMY_DATA(
ICCID VARCHAR(255),
IMSI VARCHAR(255),
PRIMARY KEY (ICCID)
);
我收到以下异常。我正在从文件中读取内容并保存在数据库中。 ICCID值将从文件中给出。其实我将文件内容值设置为ICCID,你可以帮我解决我的错误。
答案 0 :(得分:0)
Stacktrace非常明显。您必须手动设置ID或在@GeneratedValue
之上添加ICCID
注释:
@SequenceGenerator(name = "yourSEQ", sequenceName = "your_id_seq")
@Id
@Column(name = "ICCID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "yourSEQ")
private String ICCID;
当然,您必须在数据库上创建your_id_seq
序列。