The difference between save () and persist () in Hibernate
Source: Internet
Author: User
Hibernate provides the persist () method, which is almost entirely similar to the Save () function, on the one hand, to take care of the JPA usage, and the Save () and persist () methods have another difference: when you save a persisted object using the Save () method, The method returns the identity property value of the persisted object (that is, the primary key value of the corresponding record), but the method does not have any return value when the persisted object is saved using the Persist () method. Because the Save () method needs to return the identity property value of the persisted object immediately, the program execution Save () method immediately inserts the data corresponding to the persisted object into the database, while persist () guarantees that it is not immediately converted to an INSERT statement when it is called outside of a thing. This feature is useful, especially when it comes to encapsulating a long session flow, and the persist () method is especially important.
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.