Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZmE5MDhjZGJm...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-15509?atlOrigin=eyJpIjoiZmE5MD...
) HHH-15509 (
https://hibernate.atlassian.net/browse/HHH-15509?atlOrigin=eyJpIjoiZmE5MD...
) Avoid entity loading on delete() when possible (
https://hibernate.atlassian.net/browse/HHH-15509?atlOrigin=eyJpIjoiZmE5MD...
)
Issue Type: Improvement Assignee: Unassigned Components: hibernate-core Created:
14/Sep/2022 04:17 AM Fix Versions: 6.2.0 Priority: Major Reporter: Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
In some very specific cases (no lifecycle callbacks, no cascades, …), deleting an entity
could only involve running a few DB statements along the lines of delete from table where
id = ?. In those cases, loading the entity would (in theory) not be necessary.
In those very specific cases, when EntityManager.delete(Object) gets passed an
uninitialized entity proxy, it would be a nice optimization if Hibernate ORM could skip
initializing the proxy and just run the delete statements.
This would remove at least one DB lookup for users doing a “delete-by-id” such as
session.delete(session.getReference(MyEntity.class, 42L)) in some situations, while still
doing the right thing (cascades, calling listeners, …) when the optimization is not
possible.
Note I’m not sure this is possible, but it’s probably worth investigating, be it only to
document why it’s not possible.
Related discussions:
*
https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/t...
(
https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/t...
)
*
https://github.com/quarkusio/quarkus/pull/27832 (
https://github.com/quarkusio/quarkus/pull/27832 )
(
https://hibernate.atlassian.net/browse/HHH-15509#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15509#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:c85b1ee )