-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate "old" methods of session and add a new one #4590
Conversation
56894dc
to
a7d4374
Compare
94750bb
to
f1a2ac7
Compare
f1a2ac7
to
6820e1e
Compare
- deprecated load() - deprecated save(), saveOrUpdate(), and update() - deprecated delete() - deprecated "dangerous" overloads of refresh() - added getReference() taking an entity name - improved the Javadoc for lots of operations
6820e1e
to
8eb3d4e
Compare
63e8dd4
to
bf12a72
Compare
rewrite the incorrect javadoc for the class Hibernate
bf12a72
to
e1b5ded
Compare
Need to merge this, or I'm just going to get myself back into more conflict hell. Note that there are no breaking changes here, and if anyone disagrees that one of more of these methods should be deprecated then that's not a problem. Just speak up! We can undeprecate operations now or later. It's easy to remove a |
Speaking up! :) I like I always thought of |
JPA (API) unfortunatelly does not allow for a reattaching a detached object to the session. And all of the JPA entity state diagrams published everywhere, pretending I vote for keeping and supporting These methods are also much more convenient in many cases, because you can continue to work with the same object without the need of keeping in mind not to forget reassigning of the object references. |
That is correct, except it's not unfortunate. It's a good thing.
We decided not include them in JPA, because they caused so many problems in the early days of Hibernate. We should actually have deprecated them long ago. That said, there is no immediate plan to actually remove them. |
Thank you, Gavin, for your comment. I also very appreciate your work on Hibernate, JPA, and Ceylon. But it would be so much more consistent and conceptually understandable to have that transition officially supported! If you have some links to analysis/discussions of pro and contra retaining of that methods, it would help all of us, I think (besides the already mentioned possible exception that the object is already attached, which is pretty good manageable if you keep the transaction scope small). |
I understand why you want this, I really do. But that was the primary model in Hibernate for the first like 5 years of its existence and the truth is it was simply a bloodbath. There was no good way for users to be sure that some referenced object didn't already belong to the PC when they tried to call If you want to work with detached objects today, there's still a way: |
I think we're talking about 2 different types of software. There are stateful apps (which I think is what you're referring to) that benefit from Stateful apps benefit from
|
Is this the final decision? I've noticed that save, update and saveOrUpdate methods have been removed completely in Hibernate 7 (HHH-18196), despite stating that |
A replacement for that is being discussed on https://hibernate.atlassian.net/issues/HHH-18549 |
load()
save()
,saveOrUpdate()
,and update()
delete()
getReference()
taking an entity name (to replace the deprecatedload()
)As discussed here: #4520
Note that I have attempted to obtain a more consistent and readable format to the Javadoc, without quite so many raggedy long lines sticking off the side of my monitor.