Its purpose is basically the same as persist, but it has different implementation details. The save method is an “original” Hibernate method that doesn’t conform to the JPA specification. The second call to session.persist() causes an exception, so the following code won’t work: In the following example, we’ll persist the entity, evict it from the context so it becomes detached, and then try to persist again. But if we try to persist a detached instance, the implementation will throw an exception. We may call this method on an already persistent instance, and nothing happens. The id won’t necessarily be non-null after we call this method, so we shouldn’t rely upon it. The specification for the persist method allows the implementation to issue statements to generate the id on commit or flush. The spec doesn’t state that the id will generate right away, regardless of the id generation strategy. ![]() Notice that there’s nothing here that concerns the identifier of an instance.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |