[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2896?page=c...
]
Eric Dalquist commented on HHH-2896:
------------------------------------
SessionImpl will be restructured to make IdentifierLoadAccess the first-class method of
retrieving entities by primary key. All existing load and get methods will be updated to
delegate to IdentifierLoadAccess.
The initial implementation of NaturalIdLoadAccess will be a two-step process which
includes the creation of a new ResolveNaturalIdEvent event type.
# Fire a ResolveNaturalIdEvent with the entity name and natural id attribute values. This
event will resolve the primary key for the entity.
# Fire a LoadEvent using the resolved primary key and provided lock options.
A new cache to store the EntityName.[NaturalId]->PK mappings is needed. This cache will
be similar to a query cache in functionality, lookups by immutable natural id will never
do an isUpToDate check, lookups on mutable natural id's will behave very similarly to
existing query cached lookups.
The hibernate persist logic will need to be reviewed for its handling of immutable natural
id attributes. These attributes should never be included in generated SQL update
statements to enforce the immutability constraint of the natural id.
New methods to manage this new cache will need to be added to org.hibernate.Cache
{code:java}
evictNaturalKeyEntry(String entityName, Object key)
evictNaturalKeyRegion(String entityName)
{code}
Improvements that can be planned out beyond the initial feature implementation
* Extend the handling of ResolveNaturalIdEvent to load the entity into the session cache
if it is not already present, this should reduce the number of db queries by 1 for each
naturalid load that is a cache-miss.
* Add handling of the various persist/load/merge/delete events to maintain the
NaturalID->PK mappings in this new cache.
unified approach for id and natural-id loading
-----------------------------------------------
Key: HHH-2896
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2896
Project: Hibernate Core
Issue Type: Improvement
Components: core
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Fix For: 3.x
Attachments: hhh-2896_irc_discussion.txt
A follow-on to HHH-2879 in regards to unifying the loading of entities by pk or
natural-id.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira