1, problem: in the use of spring, Hibernate developed database applications, found no matter how, data can not be inserted into the database. But the program does not error, can be queried, can also be inserted.
2. Analysis: Hibernate setting Auto-commit still doesn't work, the reason is simple, it is possible that your program operation table and the table you want to manipulate is not the same table, if
the note table name in the program and the table name to be operated inconsistent , a new table will be established, for example:
@Entity
@Table (name = "SampleData")
public class SampleData implements Serializable {
The table name specified in this code is sampledata, and the table name that you actually want to manipulate is t_data.
At this point, no matter how you query the T_data in the new inserted records are not found, and repeat the insertion, but the insertion is repeated, and can fetch data.
This is a non-technical problem, but if not found in time, it is a waste of time.
3. FIX: set the name of the note table in the program to the table name of the table to be manipulated.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Spring, Hibernate data cannot be inserted into the database problem resolution