deprecate old Session methods #4520
Replies: 5 comments 3 replies
-
Another one to consider here is |
Beta Was this translation helpful? Give feedback.
-
I completely agree with dropping
I like the idea of dropping I'm not so sure about |
Beta Was this translation helpful? Give feedback.
-
The difference with update versus merge is the fact that it is the same object graph, not a copy. It is a true re-attach API |
Beta Was this translation helpful? Give feedback.
-
Not speaking to its usefulness. Just explaining the distinction for Christian |
Beta Was this translation helpful? Give feedback.
-
See #4590 |
Beta Was this translation helpful? Give feedback.
-
I think we should consider deprecating the following methods of
Session
:saveOrUpdate()
andupdate()
, andsave()
, andload()
.The
update()
andsaveOrUpdate()
operations were, essentially, a failed experiment from early in the history of Hibernate, and were replaced bymerge()
in the JPA spec. It seems clear to me that users have had many fewer problems withmerge()
than withupdate()
, and I think we probably should have deprecated these operations long ago.The
save()
operation is almost identical tosaveOrUpdate()
except that it returns an id. You can use it likepersist()
, but I thinkpersist()
is a better name anyway.The
load()
method was the first (historical) way to load an entity by id. It was originally defined to be lazy, which turned out to be annoying and confusing for users most of the time (but sometimes useful). So we added theget()
method which is defined to be eager. Unfortunately, the names of these operations were always pretty confusing: it would make more sense if they exactly reversed. Furthermore,load()
comes with overloads which acceptLockMode
s, which really don't make sense if the concept of the thing is supposed to be laziness.So in JPA these operations were named
getReference()
andfind()
respectively, and onlyfind()
acceptsLockMode
s. I think it's clear thatgetReference()
is a much, much better name thanload()
. On the other hand, I don't thinkfind()
is a better name thanget()
.So I think we could reasonably deprecate
load()
, and leaveget()
unmolested.Beta Was this translation helpful? Give feedback.
All reactions