public class Neo4jDialect extends BaseGridDialect implements MultigetGridDialect, QueryableGridDialect<String>, SessionFactoryLifecycleAwareDialect
A Tuple is saved as a Node where the columns are converted into properties of the node.
An Association is converted into a Relationship identified by the AssociationKey and the
RowKey. The type of the relationship is the value returned by
AssociationKeyMetadata.getCollectionRole().
If the value of a property is set to null the property will be removed (Neo4j does not allow to store null values).
| Modifier and Type | Field and Description |
|---|---|
static String |
CONSTRAINT_VIOLATION_CODE |
| Constructor and Description |
|---|
Neo4jDialect(Neo4jDatastoreProvider provider) |
| Modifier and Type | Method and Description |
|---|---|
Association |
createAssociation(AssociationKey associationKey,
AssociationContext associationContext)
Creates a new (empty) association for storing the tuples representing the rows corresponding to the given key.
|
Tuple |
createTuple(EntityKey key,
TupleContext tupleContext)
Creates a new tuple for the given entity key.
|
ClosableIterator<Tuple> |
executeBackendQuery(BackendQuery<String> backendQuery,
QueryParameters queryParameters)
Returns the result of a native query executed on the backend.
|
int |
executeBackendUpdateQuery(BackendQuery<String> query,
QueryParameters queryParameters)
Returns the result of a native update query executed on the backend.
|
void |
forEachTuple(ModelConsumer consumer,
TupleContext tupleContext,
EntityKeyMetadata entityKeyMetadata)
A consumer is called for each tuple matching the selected
EntityKeyMetadata. |
Association |
getAssociation(AssociationKey associationKey,
AssociationContext associationContext)
Return the list of tuples corresponding to a given association and the given context
|
DuplicateInsertPreventionStrategy |
getDuplicateInsertPreventionStrategy(EntityKeyMetadata entityKeyMetadata)
Returns this dialect's strategy for detecting the insertion of several entity tuples of the given type with the
same primary key.
|
ParameterMetadataBuilder |
getParameterMetadataBuilder()
Returns a builder for retrieving parameter meta-data from native queries in this datastore's format.
|
Tuple |
getTuple(EntityKey key,
TupleContext context)
Return the tuple with the given column for a given key
|
List<Tuple> |
getTuples(EntityKey[] keys,
TupleContext tupleContext)
Return the list of tuples with the given columns for a given list of keys.
|
void |
insertOrUpdateAssociation(AssociationKey key,
Association association,
AssociationContext associationContext)
Inserts or updates the given association in the datastore.
|
void |
insertOrUpdateTuple(EntityKey key,
Tuple tuple,
TupleContext tupleContext)
Inserts or updates the tuple corresponding to the given entity key.
|
static boolean |
isPartOfRegularEmbedded(String[] keyColumnNames,
String column)
A regular embedded is an element that it is embedded but it is not a key or a collection.
|
boolean |
isStoredInEntityStructure(AssociationKeyMetadata associationKeyMetadata,
AssociationTypeContext associationTypeContext)
Whether the specified association is stored within an entity structure or not.
|
Number |
nextValue(NextValueRequest request)
Returns the next value from the specified id generator with the specified increment.
|
GridType |
overrideType(Type type)
If the datastore does not support a
Type the dialect might override it with a custom one. |
String |
parseNativeQuery(String nativeQuery)
Parses the given native query into a representation executable by this dialect.
|
void |
removeAssociation(AssociationKey key,
AssociationContext associationContext)
Remove the list of tuples corresponding to a given association
|
void |
removeTuple(EntityKey key,
TupleContext tupleContext)
Remove the tuple for a given key
|
void |
sessionFactoryCreated(SessionFactoryImplementor sessionFactoryImplementor)
Injection point for the dialect to receive the session factory.
|
boolean |
supportsSequences()
Whether this dialect supports sequences for id generation or not.
|
getLockingStrategyequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLockingStrategypublic static final String CONSTRAINT_VIOLATION_CODE
public Neo4jDialect(Neo4jDatastoreProvider provider)
public void sessionFactoryCreated(SessionFactoryImplementor sessionFactoryImplementor)
SessionFactoryLifecycleAwareDialectsessionFactoryCreated in interface SessionFactoryLifecycleAwareDialectsessionFactoryImplementor - a successfully created SessionFactoryImplementorpublic Tuple getTuple(EntityKey key, TupleContext context)
GridDialectgetTuple in interface GridDialectkey - The tuple identifiercontext - Contains additional information that might be used to create the tuplepublic List<Tuple> getTuples(EntityKey[] keys, TupleContext tupleContext)
MultigetGridDialect
All the keys provided will have the same EntityKeyMetadata.
In other words they target the same "table".
getTuples in interface MultigetGridDialectkeys - The array of tuple identifiertupleContext - Contains additional information that might be used to create the tuplespublic Tuple createTuple(EntityKey key, TupleContext tupleContext)
GridDialect
Only invoked if no tuple is present yet for the given key. Implementations should not perform a round-trip to the
datastore but rather return a transient instance. The OGM engine will invoke
GridDialect.insertOrUpdateTuple(EntityKey, Tuple, TupleContext) subsequently.
Columns in the tuple may represent properties of the corresponding entity as well as *-to-one associations to other entities. Implementations may choose to persist the latter e.g. in form of fields or as actual links/relationships to the element representing the associated entity. In case of multi-column keys, the corresponding association role for a given column can be obtained from the passed tuple context.
createTuple in interface GridDialectkey - The tuple identifiertupleContext - Contains additional information that might be used to create the tuplepublic void insertOrUpdateTuple(EntityKey key, Tuple tuple, TupleContext tupleContext)
GridDialectinsertOrUpdateTuple in interface GridDialectkey - The tuple identifiertuple - The list of operations to executetupleContext - Contains additional information that might be used to create or update the tuplepublic void removeTuple(EntityKey key, TupleContext tupleContext)
GridDialectremoveTuple in interface GridDialectkey - The tuple identifiertupleContext - Contains additional information that might be used to remove the tuplepublic Association getAssociation(AssociationKey associationKey, AssociationContext associationContext)
GridDialectgetAssociation in interface GridDialectassociationKey - Identifies the associationassociationContext - Contains additional information that might be used to get the associationpublic Association createAssociation(AssociationKey associationKey, AssociationContext associationContext)
GridDialect
Only invoked if the association does not yet exist in the datastore. Implementations should not perform a
round-trip to the datastore but rather return a transient instance. The OGM engine will invoke
GridDialect.insertOrUpdateAssociation(AssociationKey, Association, AssociationContext) subsequently.
createAssociation in interface GridDialectassociationKey - Identifies the associationassociationContext - Contains additional information that might be used to create the associationpublic void insertOrUpdateAssociation(AssociationKey key, Association association, AssociationContext associationContext)
GridDialectinsertOrUpdateAssociation in interface GridDialectkey - Identifies the associationassociation - The list of operations to executeassociationContext - Contains additional information that might be used to create the associationpublic boolean isStoredInEntityStructure(AssociationKeyMetadata associationKeyMetadata, AssociationTypeContext associationTypeContext)
GridDialecttrue if this is the
case for a given association.isStoredInEntityStructure in interface GridDialectassociationKeyMetadata - identifies the association of interestassociationTypeContext - provides additional contextual information about the represented association type,
such as the options effectively applying for ittrue if the specified association is stored within an entity structure, false otherwise.public Number nextValue(NextValueRequest request)
GridDialectnextValue in interface GridDialectrequest - Identifies a specific id generatorpublic boolean supportsSequences()
GridDialectsupportsSequences in interface GridDialectsupportsSequences in class BaseGridDialecttrue if this dialect supports sequences, false otherwise.public GridType overrideType(Type type)
GridDialectType the dialect might override it with a custom one.overrideType in interface GridDialectoverrideType in class BaseGridDialecttype - The Type that might need to be overriddentype or null if the type does not need to be
overriddenpublic void removeAssociation(AssociationKey key, AssociationContext associationContext)
GridDialectremoveAssociation in interface GridDialectkey - Identifies the associationassociationContext - Contains additional information that might be used to remove an associationpublic static boolean isPartOfRegularEmbedded(String[] keyColumnNames, String column)
keyColumnNames - the column names representing the identifier of the entitycolumn - the column we want to checktrue if the column represent an attribute of a regular embedded element, false otherwisepublic void forEachTuple(ModelConsumer consumer, TupleContext tupleContext, EntityKeyMetadata entityKeyMetadata)
GridDialectEntityKeyMetadata. The tuples must be of the
same indexed type.forEachTuple in interface GridDialectconsumer - the instance that is going to be called for every TupletupleContext - contains additional information that might be used to build the tupleentityKeyMetadata - the key metadata of the table for which we want to apply the consumerpublic ClosableIterator<Tuple> executeBackendQuery(BackendQuery<String> backendQuery, QueryParameters queryParameters)
QueryableGridDialectexecuteBackendQuery in interface QueryableGridDialect<String>backendQuery - the query to execute in a representation understood by the underlying datastore. May have been
created by converting a JP-QL query or from a (named) native query.queryParameters - parameters passed for this queryClosableIterator with the result of the querypublic int executeBackendUpdateQuery(BackendQuery<String> query, QueryParameters queryParameters)
QueryableGridDialectPrecise semantics of an update are subject to design choices made for the actual database system in the backend. In particular, it may implement non-classical notions of consistency such as eventual consistency (rather than (conflict) serializablity as in most relational SQL database systems).
executeBackendUpdateQuery in interface QueryableGridDialect<String>query - the query to execute in a representation understood by the underlying datastore. May have been
created by converting a JP-QL query or from a (named) native query.queryParameters - parameters passed for this querypublic String parseNativeQuery(String nativeQuery)
QueryableGridDialectparseNativeQuery in interface QueryableGridDialect<String>nativeQuery - the native query to parsepublic ParameterMetadataBuilder getParameterMetadataBuilder()
QueryableGridDialectgetParameterMetadataBuilder in interface QueryableGridDialect<String>public DuplicateInsertPreventionStrategy getDuplicateInsertPreventionStrategy(EntityKeyMetadata entityKeyMetadata)
GridDialectgetDuplicateInsertPreventionStrategy in interface GridDialectgetDuplicateInsertPreventionStrategy in class BaseGridDialectentityKeyMetadata - meta-data identifying the entity type of interestCopyright © 2010-2017 Red Hat, Inc., Emmanuel Bernard and various contributors. All Rights Reserved.