Class Neo4jSession

java.lang.Object
org.neo4j.ogm.session.Neo4jSession
All Implemented Interfaces:
Session

public class Neo4jSession extends Object implements Session
Author:
Vince Bickers, Luanne Misquitta, Mihai Raulea, Mark Angrish, Michael J. Simons
  • Constructor Details

    • Neo4jSession

      public Neo4jSession(MetaData metaData, boolean useStrictQuerying, org.neo4j.ogm.driver.Driver driver)
  • Method Details

    • register

      public EventListener register(EventListener eventListener)
      Description copied from interface: Session
      Register an event listener with this session.
      Specified by:
      register in interface Session
      Parameters:
      eventListener - The listener to register.
      Returns:
      the registered event listener.
    • notifyListeners

      public void notifyListeners(Event event)
      Description copied from interface: Session
      Notifies listeners of this session of the supplied Event.
      Specified by:
      notifyListeners in interface Session
      Parameters:
      event - The event to inform listeners with.
    • eventsEnabled

      public boolean eventsEnabled()
      Description copied from interface: Session
      Determines if events are enabled for this session.
      Specified by:
      eventsEnabled in interface Session
      Returns:
      true if this session allows events.
    • dispose

      public boolean dispose(EventListener eventListener)
      Description copied from interface: Session
      Remove an event listener from this session.
      Specified by:
      dispose in interface Session
      Parameters:
      eventListener - The listener to deregister
      Returns:
      true if successfully registered.
    • load

      public <T, ID extends Serializable> T load(Class<T> type, ID id)
      Description copied from interface: Session
      Load single entity instance of type, with default depth = 1
      Specified by:
      load in interface Session
      Returns:
      entity instance, null if not found
    • load

      public <T, ID extends Serializable> T load(Class<T> type, ID id, int depth)
      Description copied from interface: Session
      Load single entity instance of type, with depth
      Specified by:
      load in interface Session
      Returns:
      entity instance, null if not found
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type)
      Description copied from interface: Session
      Load all entities of type, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, int depth)
      Description copied from interface: Session
      Load all entities of type, with depth
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Pagination paging)
      Description copied from interface: Session
      Load all entities of type, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      paging - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Pagination paging, int depth)
      Description copied from interface: Session
      Load all entities of type.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      paging - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, SortOrder sortOrder)
      Description copied from interface: Session
      Load all entities of type, with default depth = 1
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      sortOrder - sort order
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, SortOrder sortOrder, int depth)
      Description copied from interface: Session
      Load all entities of type.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      sortOrder - sort order
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, SortOrder sortOrder, Pagination pagination)
      Description copied from interface: Session
      Load all entities of type, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      sortOrder - sort order
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, SortOrder sortOrder, Pagination pagination, int depth)
      Description copied from interface: Session
      Load all entities of type.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      sortOrder - sort order
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter)
      Description copied from interface: Session
      Load all entities of type, filtered by filter, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filter.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, SortOrder sortOrder)
      Description copied from interface: Session
      Load all entities of type, filtered by filter, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      sortOrder - sort order
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, SortOrder sortOrder, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filter.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      sortOrder - sort order
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, Pagination pagination)
      Description copied from interface: Session
      Load all entities of type, filtered by filter, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, Pagination pagination, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filter.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, SortOrder sortOrder, Pagination pagination)
      Description copied from interface: Session
      Load all entities of type, filtered by filter, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      sortOrder - sort order
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filter filter, SortOrder sortOrder, Pagination pagination, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filter.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filter - filter
      sortOrder - sort order
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters)
      Description copied from interface: Session
      Load all entities of type, filtered by filters, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filters.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder)
      Description copied from interface: Session
      Load all entities of type, filtered by filters, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      sortOrder - sort order
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filters.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      sortOrder - sort order
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, Pagination pagination)
      Description copied from interface: Session
      Load all entities of type, filtered by filters, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, Pagination pagination, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filters.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, Pagination pagination)
      Description copied from interface: Session
      Load all entities of type, filtered by filters, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      sortOrder - sort order
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Class<T> type, Filters filters, SortOrder sortOrder, Pagination pagination, int depth)
      Description copied from interface: Session
      Load all entities of type, filtered by filters.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      filters - filters
      sortOrder - sort order
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids)
      Description copied from interface: Session
      Load entities of type by their ids, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, int depth)
      Description copied from interface: Session
      Load entities of type by their ids.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, SortOrder sortOrder)
      Description copied from interface: Session
      Load entities of type by their ids, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      sortOrder - sort order
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, SortOrder sortOrder, int depth)
      Description copied from interface: Session
      Load entities of type by their ids.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      sortOrder - sort order
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, Pagination paging)
      Description copied from interface: Session
      Load entities of type by their ids, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      paging - pagination
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, Pagination paging, int depth)
      Description copied from interface: Session
      Load entities of type by their ids.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      paging - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, SortOrder sortOrder, Pagination pagination)
      Description copied from interface: Session
      Load entities of type by their ids, with default depth = 1.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      sortOrder - sort order
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T, ID extends Serializable> Collection<T> loadAll(Class<T> type, Collection<ID> ids, SortOrder sortOrder, Pagination pagination, int depth)
      Description copied from interface: Session
      Load entities of type by their ids.
      Specified by:
      loadAll in interface Session
      Parameters:
      type - type of entities
      ids - ids of entities to load
      sortOrder - sort order
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again, with default depth = 1. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, int depth)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, SortOrder sortOrder)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again, with default depth = 1. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      sortOrder - sort order
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, SortOrder sortOrder, int depth)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      sortOrder - sort order
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, Pagination pagination)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again, with default depth = 1. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, Pagination pagination, int depth)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, SortOrder sortOrder, Pagination pagination)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again, with default depth = 1. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      sortOrder - sort order
      pagination - pagination
      Returns:
      collection of entities
    • loadAll

      public <T> Collection<T> loadAll(Collection<T> objects, SortOrder sortOrder, Pagination pagination, int depth)
      Description copied from interface: Session
      Load entities by themselves - uses id of the entity to load it again. Note that standard session behaviour regarding entity loading an reloading applies.
      Specified by:
      loadAll in interface Session
      Parameters:
      objects - objects
      sortOrder - sort order
      pagination - pagination
      depth - depth
      Returns:
      collection of entities
    • queryForObject

      public <T> T queryForObject(Class<T> type, String cypher, Map<String,?> parameters)
      Description copied from interface: Session
      a cypher statement this method will return a domain object that is hydrated to the default level or a scalar (depending on the parametrized type).
      Specified by:
      queryForObject in interface Session
      Type Parameters:
      T - A domain object or scalar.
      Parameters:
      type - The type that should be returned from the query.
      cypher - The parameterizable cypher to execute.
      parameters - Any scalar parameters to attach to the cypher.
      Returns:
      An instance of the objectType that matches the cypher and parameters. Null if no object is matched
    • query

      public <T> Iterable<T> query(Class<T> type, String cypher, Map<String,?> parameters)
      Description copied from interface: Session
      a cypher statement this method will return a collection of domain objects that is hydrated to the default level or a collection of scalars (depending on the parametrized type).
      Specified by:
      query in interface Session
      Type Parameters:
      T - A domain object or scalar.
      Parameters:
      type - The type that should be returned from the query.
      cypher - The parameterizable cypher to execute.
      parameters - Any parameters to attach to the cypher.
      Returns:
      A collection of domain objects or scalars as prescribed by the parametrized type.
    • query

      public org.neo4j.ogm.model.Result query(String cypher, Map<String,?> parameters)
      Description copied from interface: Session
      a cypher statement this method will return a Result object containing a collection of Map's which represent Neo4j objects as properties, along with query statistics if applicable. Each element of the query result is a map which you can access by the name of the returned field TODO: Are we going to use the neo4jOperations conversion method to cast the value object to its proper class?
      Specified by:
      query in interface Session
      Parameters:
      cypher - The parameterisable cypher to execute.
      parameters - Any parameters to attach to the cypher.
      Returns:
      A Result containing an Iterable map representing query results and QueryStatistics if applicable.
    • queryDto

      public <T> List<T> queryDto(String cypher, Map<String,?> parameters, Class<T> type)
      Description copied from interface: Session
      Map non-entities to a List of DTO objects.
      Specified by:
      queryDto in interface Session
      Type Parameters:
      T - Type of the expected result.
      Parameters:
      cypher - The parameterisable cypher to execute.
      parameters - Any parameters to attach to the cypher.
      type - The tyoe that should be returned from the query.
      Returns:
      A List of the resulting object.
    • query

      public org.neo4j.ogm.model.Result query(String cypher, Map<String,?> parameters, boolean readOnly)
      Description copied from interface: Session
      a cypher statement this method will return a Result object containing a collection of Map's which represent Neo4j objects as properties, along with query statistics if applicable. Each element of the query result is a map which you can access by the name of the returned field TODO: Are we going to use the neo4jOperations conversion method to cast the value object to its proper class?
      Specified by:
      query in interface Session
      Parameters:
      cypher - The parameterisable cypher to execute.
      parameters - Any parameters to attach to the cypher.
      readOnly - true if the query is readOnly, false otherwise
      Returns:
      A Result of Iterables with each entry representing a neo4j object's properties.
    • countEntitiesOfType

      public long countEntitiesOfType(Class<?> entity)
      Description copied from interface: Session
      Counts all the node entities of the specified type.
      Specified by:
      countEntitiesOfType in interface Session
      Parameters:
      entity - The Class denoting the type of entity to count
      Returns:
      The number of entities in the database of the type
    • count

      public long count(Class<?> clazz, Iterable<Filter> filters)
      Description copied from interface: Session
      Counts all the node entities of the specified type which match the filters supplied
      Specified by:
      count in interface Session
      Parameters:
      clazz - The Class denoting the type of entity to count
      filters - a collection of Filter objects used as additional parameters to the query
      Returns:
      The number of entities in the database of the type matched by the filters
    • purgeDatabase

      public void purgeDatabase()
      Description copied from interface: Session
      Delete all nodes in the database. The delete is performed in a single transaction so it may not be suitable for large data sets. NOTE: This will delete all data, not only nodes/relationships with matching metadata in the domain.
      Specified by:
      purgeDatabase in interface Session
    • delete

      public <T> void delete(T object)
      Description copied from interface: Session
      Delete entity (or entities)
      Specified by:
      delete in interface Session
      Parameters:
      object - object to delete, may be single entity, array of entities or Iterable
    • deleteAll

      public <T> void deleteAll(Class<T> type)
      Description copied from interface: Session
      Delete all entities of type
      Specified by:
      deleteAll in interface Session
      Parameters:
      type - type of the entities to delete
    • delete

      public <T> Object delete(Class<T> type, Iterable<Filter> filters, boolean listResults)
      Description copied from interface: Session
      Delete all entities of type matching filter
      Specified by:
      delete in interface Session
      Parameters:
      type - type of the entities to delete
      filters - filters to match entities to delete
      listResults - true if ids of deleted entities should be returned, false to return count only
      Returns:
      ids or deleted entities or count of deleted entities
    • save

      public <T> void save(T object)
      Description copied from interface: Session
      Save entity(or entities) into the database, up to specified depth The entities are either created or updated. When new objects are saved and the objects have a field that is mapped with Id using the internal Id-generation-strategy, those fields are modified and set to the internal graph-id.
      Specified by:
      save in interface Session
      Parameters:
      object - object to save, may be single entity, array of entities or Iterable
    • save

      public <T> void save(T object, int depth)
      Description copied from interface: Session
      Save entity(or entities) into the database, up to specified depth The objects are either created or updated. When new objects are saved and the objects have a field that is mapped with Id using the internal Id-generation-strategy, those fields are modified and set to the internal graph-id.
      Specified by:
      save in interface Session
      Parameters:
      object - object to save, may be single entity, array of entities or Iterable
    • addWriteProtection

      public void addWriteProtection(WriteProtectionTarget target, Predicate<Object> protection)
      Adds a Predicate as possible write protection for the specified target. OGM will pass the entity that currently is persisted to the predicate and will skip writing or updating it (depending on the mode) when the predicate returns true.
      If setWriteProtectionStrategy(WriteProtectionStrategy) has been used to apply a custom strategy, is has to be used with null again to remove the custom write protection strategy before applying the simple one here.
      Parameters:
      target - The target to which the write protection should be applied
      protection - A predicate determines per entity if write protection has to be applied or node.
    • removeWriteProtection

      public void removeWriteProtection(WriteProtectionTarget target)
      Removes write protection for the specified mode.
      Parameters:
      target - The target to remove all write protections for.
    • setWriteProtectionStrategy

      public void setWriteProtectionStrategy(WriteProtectionStrategy writeProtectionStrategy)
      Can be used to apply a completely custom write protection strategy.
      Parameters:
      writeProtectionStrategy -
    • beginTransaction

      public org.neo4j.ogm.transaction.Transaction beginTransaction()
      Description copied from interface: Session
      Begin a new READ_WRITE transaction. If an existing transaction already exists, users must decide whether to commit or rollback. Only one transaction can be bound to a thread at any time, so active transactions that have not been closed but are no longer bound to the thread must be handled by client code.
      Specified by:
      beginTransaction in interface Session
      Returns:
      a new active Transaction
    • beginTransaction

      public org.neo4j.ogm.transaction.Transaction beginTransaction(org.neo4j.ogm.transaction.Transaction.Type type)
      Description copied from interface: Session
      Begin a new transaction, passing in the required type (READ_ONLY, READ_WRITE). If an existing transaction already exists, users must decide whether to commit or rollback. Only one transaction can be bound to a thread at any time, so active transactions that have not been closed but are no longer bound to the thread must be handled by client code.
      Specified by:
      beginTransaction in interface Session
      Parameters:
      type - the Transaction.Type required for this transaction
      Returns:
      a new active Transaction
    • beginTransaction

      public org.neo4j.ogm.transaction.Transaction beginTransaction(org.neo4j.ogm.transaction.Transaction.Type type, Iterable<String> bookmarks)
      Description copied from interface: Session
      Begin a new transaction, passing in the required type and bookmarks If an existing transaction already exists, users must decide whether to commit or rollback. Only one transaction can be bound to a thread at any time, so active transactions that have not been closed but are no longer bound to the thread must be handled by client code.
      Specified by:
      beginTransaction in interface Session
      Parameters:
      type - the Transaction.Type required for this transaction
      bookmarks - bookmarks that are passed to driver
      Returns:
      a new active Transaction
    • doInTransaction

      public void doInTransaction(TransactionalUnitOfWorkWithoutResult function, org.neo4j.ogm.transaction.Transaction.Type txType)
      Parameters:
      function - The code to execute.
      txType - Transaction type, readonly or not.
      See Also:
    • doInTransaction

      public void doInTransaction(TransactionalUnitOfWorkWithoutResult function, boolean forceTx, org.neo4j.ogm.transaction.Transaction.Type txType)
    • doInTransaction

      public <T> T doInTransaction(TransactionalUnitOfWork<T> function, org.neo4j.ogm.transaction.Transaction.Type txType)
    • doInTransaction

      public <T> T doInTransaction(TransactionalUnitOfWork<T> function, boolean forceTx, org.neo4j.ogm.transaction.Transaction.Type txType)
      For internal use only. Opens a new transaction if necessary before running statements in case an explicit transaction does not exist. It is designed to be the central point for handling exceptions coming from the DB and apply commit / rollback rules.
      Type Parameters:
      T - The result type.
      Parameters:
      function - The callback to execute.
      txType - Transaction type, readonly or not.
      Returns:
      The result of the transaction function.
    • getTransaction

      public org.neo4j.ogm.transaction.Transaction getTransaction()
      Description copied from interface: Session
      Get the existing transaction if available
      Specified by:
      getTransaction in interface Session
      Returns:
      an active Transaction, or null if none exists
    • getTransactionManager

      public org.neo4j.ogm.transaction.TransactionManager getTransactionManager()
      This is a convenience method that one can use to access a custom transaction manager that may or may not have special requirements or additional functionality. While not part of session interface, it is safe to use after down-casting to Neo4jSession
      Returns:
      This sessions transaction manager.
      Since:
      4.0.3
    • resolveGraphIdFor

      public Long resolveGraphIdFor(Object possibleEntity)
      Description copied from interface: Session
      Resolve the graph id for a possible entity.
      Specified by:
      resolveGraphIdFor in interface Session
      Parameters:
      possibleEntity - the possible entity
      Returns:
      the value of the internal graph id for the possible entity. Returns null if either the object is not an entity or the id is null.
    • detachNodeEntity

      public boolean detachNodeEntity(Long id)
      Description copied from interface: Session
      Detach this node entity represented by the supplied Graph ID from the session.
      Specified by:
      detachNodeEntity in interface Session
      Parameters:
      id - the node id to detach.
      Returns:
      true if detached successfully.
    • detachRelationshipEntity

      public boolean detachRelationshipEntity(Long id)
      Description copied from interface: Session
      Detach this relationship entity represented by the supplied Graph ID from the session.
      Specified by:
      detachRelationshipEntity in interface Session
      Parameters:
      id - the relationship id to detach.
      Returns:
      true if detached successfully.
    • queryStatementsFor

      public <T, ID extends Serializable> QueryStatements<ID> queryStatementsFor(Class<T> type, int depth)
    • determineLabelsOrTypeForLoading

      public Optional<String> determineLabelsOrTypeForLoading(Class<?> type)
      Determines the one relationship type or maybe multiple labels to use in various statements during loading of things.

      Multiple labels are pre-joined with

      `:`
      . There are meant to be passed to various clause builders, which cannot deal with list of labels, but use the one label or type and use it in between tickmarks.
      Parameters:
      type - The type of the objects that shall be loaded
      Returns:
      Label(s) or type, empty optional of no valid label or type could be determined.
    • context

      public MappingContext context()
    • optimisticLockingChecker

      public OptimisticLockingChecker optimisticLockingChecker()
    • metaData

      public MetaData metaData()
    • clear

      public void clear()
      Description copied from interface: Session
      Clears the Session
      Specified by:
      clear in interface Session
    • requestHandler

      public org.neo4j.ogm.request.Request requestHandler()
    • warn

      public void warn(String msg)
    • getLastBookmark

      public String getLastBookmark()
      Description copied from interface: Session
      Retrieves the last bookmark used in this session when used in a Neo4j Causal Cluster. This bookmark can be used to ensure the cluster is consistent before performing a read/write.
      Specified by:
      getLastBookmark in interface Session
      Returns:
      The last used bookmark String on this session.
    • withBookmark

      public void withBookmark(String bookmark)
      Description copied from interface: Session
      Sets the bookmark to use on this session. Useful when resuming a user session with a causal cluster.
      Specified by:
      withBookmark in interface Session
      Parameters:
      bookmark - The last used bookmark String that this session should start from.
    • getLoadStrategy

      public LoadStrategy getLoadStrategy()
      Description copied from interface: Session
      Returns current load strategy
      Specified by:
      getLoadStrategy in interface Session
      Returns:
      load strategy
    • getEntityInstantiator

      public EntityInstantiator getEntityInstantiator()
    • setLoadStrategy

      public void setLoadStrategy(LoadStrategy loadStrategy)
      Description copied from interface: Session
      Sets the LoadStrategy Will be used for all subsequent queries.
      Specified by:
      setLoadStrategy in interface Session