## org.hibernate
Interface NaturalIdLoadAccess

    public interface NaturalIdLoadAccess

Loads an entity by its natural identifier

See Also:
  `NaturalId`

Method Summary
`Object` `getReference()` Return the persistent instance with the natural id value(s) defined by the call(s) to `using(java.lang.String, java.lang.Object)`.
`Object` `load()` Return the persistent instance with the natural id value(s) defined by the call(s) to `using(java.lang.String, java.lang.Object)`, or `null` if there is no such persistent instance.
`NaturalIdLoadAccess` `setSynchronizationEnabled(boolean enabled)` For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups? The default is to perform "synchronization" (for correctness).
`NaturalIdLoadAccess` `using(String attributeName, Object value)` Add a NaturalId attribute value.
`NaturalIdLoadAccess` `with(LockOptions lockOptions)` Specify the `LockOptions` to use when retrieving the entity.

Method Detail

### with

    NaturalIdLoadAccess with(LockOptions lockOptions)

  Specify the `LockOptions` to use when retrieving the entity.

  Parameters:
    `lockOptions` - The lock options to use.
  Returns:
    `this`, for method chaining

### using

    NaturalIdLoadAccess using(String attributeName,
                              Object value)

  Add a NaturalId attribute value.

  Parameters:
    `attributeName` - The entity attribute name that is marked as a NaturalId
    `value` - The value of the attribute
  Returns:
    `this`, for method chaining

### setSynchronizationEnabled

    NaturalIdLoadAccess setSynchronizationEnabled(boolean enabled)

  For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups? The default is to perform "synchronization" (for correctness).

  "synchronization" here indicates updating the natural-id -> pk cross reference maintained as part of the session. When enabled, prior to performing the lookup, Hibernate will check all entities of the given type associated with the session to see if its natural-id values have changed and, if so, update the cross reference. There is a performance impact associated with this, so if application developers are certain the natural-ids in play have not changed, this setting can be disabled to circumvent that impact. However, disabling this setting when natural-ids values have changed can result in incorrect results!

  Parameters:
    `enabled` - Should synchronization be performed? `true` indicates synchronization will be performed; `false` indicates it will be circumvented.
  Returns:
    `this`, for method chaining

### getReference

    Object getReference()

  Return the persistent instance with the natural id value(s) defined by the call(s) to `using(java.lang.String, java.lang.Object)`. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed. You should not use this method to determine if an instance exists; to check for existence, use `load()` instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.

  Returns:
    the persistent instance or proxy

### load

    Object load()

  Return the persistent instance with the natural id value(s) defined by the call(s) to `using(java.lang.String, java.lang.Object)`, or `null` if there is no such persistent instance. If the instance is already associated with the session, return that instance, initializing it if needed. This method never returns an uninitialized instance.

  Returns:
    The persistent instance or `null`

Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.