Я использую JPA, Spring, Ext js 4 mvc и сервер mysql5.0
Одна проблема, с которой я сталкиваюсь, заключается в том, что я не могу вставить свои данные в базу данных, используя Hibernate + JPA.Я отправляю данные на серверную часть с помощью JSON, а затем этот объект взаимодействует с базой данных и вставляет объект json в базу данных.
Я отправляю данные json как
"Id": null,
"Name": "New task",
"StartDate": "2010-02-13T05:30:00",
"EndDate": "2010-02-13T05:30:00",
"Duration": 0,
"DurationUnit": "d",
"PercentDone": 0,
"ManuallyScheduled": false,
"Priority": 1,
"parentId": 22,
"index": 2,
"depth": 2,
"checked": null
my HibernatePOJO равен
private int id;
private Date startDate;
private Date endDate;
private int percentDone;
private String name;
private int priority;
private double duration;
private String durationUnit;
private int index;
private int depth;
private int parentId;
/**
* @return the id
*/
@Id
@GeneratedValue
@Column(name = "TASK_Id")
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int Id) {
this.id = Id;
}
/**
* @return the startDate
*/
@Temporal(TemporalType.DATE)
@Column(name = "TASK_Start_Date")
public Date getStartDate() {
return startDate;
}
/**
* @param startDate the startDate to set
*/
public void setStartDate(Date StartDate) {
this.startDate = StartDate;
}
/**
* @return the endDate
*/
@Temporal(TemporalType.DATE)
@Column(name = "TASK_End_Date")
public Date getEndDate() {
return endDate;
}
/**
* @param endDate the endDate to set
*/
public void setEndDate(Date EndDate) {
this.endDate = EndDate;
}
/**
* @return the percentDone
*/
@Column(name = "TASK_Percent_Done")
public int getPercentDone() {
return percentDone;
}
/**
* @param percentDone the percentDone to set
*/
public void setPercentDone(int PercentDone) {
this.percentDone = PercentDone;
}
/**
* @return the name
*/
@Column(name = "TASK_Name")
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String Name) {
this.name = Name;
}
/**
* @return the priority
*/
@Column(name = "TASK_Priority")
public int getPriority() {
return priority;
}
/**
* @param priority the priority to set
*/
public void setPriority(int Priority) {
this.priority = Priority;
}
/**
* @return the duration
*/
@Column(name = "TASK_Duration")
public double getDuration() {
return duration;
}
/**
* @param duration the duration to set
*/
public void setDuration(double Duration) {
this.duration = Duration;
}
/**
* @return the durationUnit
*/
@Column(name = "TASK_DurationUnit")
public String getDurationUnit() {
return durationUnit;
}
/**
* @param durationUnit the durationUnit to set
*/
public void setDurationUnit(String DurationUnit) {
this.durationUnit = DurationUnit;
}
/**
* @return the index
*/
@Column(name = "TASK_Index")
public int getIndex() {
return index;
}
/**
* @param index the index to set
*/
public void setIndex(int index) {
this.index = index;
}
/**
* @return the depth
*/
@Column(name = "TASK_Depth")
public int getDepth() {
return depth;
}
/**
* @param depth the depth to set
*/
public void setDepth(int depth) {
this.depth = depth;
}
/**
* @return the parentId
*/
@Column(name = "TASK_ParentId")
public int getParentId() {
return parentId;
}
/**
* @param parentId the parentId to set
*/
public void setParentId(int parentId) {
this.parentId = parentId;
}
, когда я передаю вышеуказанные данные JSON, в мою базу данных ничего не вставляется.мой запрос гибернации запускается как
`Hibernate: insert into TASK(TASK_Depth, TASK_Duration, TASK_DurationUnit, TASK_End_Date, TASK_Index, TASK_Name, TASK_ParentId, TASK_Percent_Done, TASK_Priority, TASK_Start_Date)
values( ? , ?, ?, ?, ?, ?, ?, ?, ?, ?)`
ничего не вставляется в мою базу данных.Поскольку мой идентификатор класса автоматически инкриминируется, запись создается с пустым именем, startDate, endDate, parentId
Так что мой вопрос в том, что я делаю неправильно.Есть ли какие-либо проблемы с моими отображениями в режиме гиберна Pojo.Если да, то любой, имеющий решение этой проблемы, может ответить в моей теме.