Hi,
I work on an application using JPA and Mysql. I can't create an object "subject"
My object subject
Code:
public class Subject implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -6667237497292561396L;
private Integer subId;
private Integer subCenter;
.... other properties.........
@Id
@Column(name = "SUB_ID", unique = true, nullable = false, precision = 9, scale = 0)
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getSubId() {
return this.subId;
}
....................
...................
The code where I create a subject
Code:
Subject subject = new RSubject();
subject.setSubCenter(centerId);
.... setting other properties.........
newSubject = (Subject)subjectDao.create(subject);
and I get the following error :
Code:
JDBCExceptionReporter [ERROR] Field 'SUB_ID' doesn't have a default value
I tried to set a default value to subId (private Integer subId =new Integer(0);), but I have the same error message
Thank you in advance for your answers