Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Moving on through the CRUD operations, you have yet to cover updating and deleting. In this lesson, you again use the Hibernate `Session` to perform these operations.
Note:
The .update()
and .delete()
methods in Hibernate are deprecated. They still work as expected, though you may see warnings in your IDE. It is now recommended to use .merge()
for updating detached entities and .remove()
for deleting entities.
If you previously utilized .persist()
in place of the deprecated .save()
, note that .persist()
does not return the entity's ID. To retrieve the ID after persisting, simply access it using the getter (e.g., entity.getId()
) after the transaction is committed, as the entity becomes managed and its ID is automatically generated.
Hibernate Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up