Spring, Hibernate data cannot be inserted into the database problem resolution

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.