Method to solve the problem of invalid hibernate 4 execution of save() or update()
Recently, I encountered a problem when writing the online mall project: Hibernate did not have any effect after executing the save () or update () method, there were no changes in the database, and there were no errors reported on the console, which made me speechless... I checked on the Internet. Some people said it was the self growth of the primary key, and some said it was not started, Therefore, I can't write or update the database. I read their analysis in detail, and they all make sense, but these solutions don't work for me, because my primary key is OK, the transaction is managed by spring, and other save operations are OK. Since there are no problems objectively, I focused on the specific objects to be saved or updated, and made a careful analysis of POJOs. First, take a look at the tables in the database corresponding to the objects I want to save:
Then, the specific POJO will not be posted, that is, some field properties and set and get methods generated according to this table. I think the most likely problem field is the time date, so I read the code about date in POJO:
So I searched the timestamp on the Internet again and found that the problem was here. I changed the timestamp to Java util. Date. Then a date object is passed in, and Hibernate will automatically convert to timestamp type. This problem also gives me an enlightenment: the failure to perform database operations may also be the problem of the object itself. Check between the table fields and POJO attributes.
Original link: http://blog.csdn.net/eson_15/article/details/51383298
The above is the whole content of this article. I hope it will be helpful to your study.