public class SessionFactory extends Object
Session instances for interacting with Neo4j.
In a typical scenario one instance of SessionFactory is created, shared across whole application.| Constructor and Description |
|---|
SessionFactory(Configuration configuration,
String... packages)
Constructs a new
SessionFactory by initialising the object-graph mapping meta-data from the given list of domain
object packages, and also sets the baseConfiguration to be used. |
SessionFactory(Driver driver,
String... packages)
Create a session factory with given driver
Use this constructor when you need to provide fully customized driver.
|
SessionFactory(String... packages)
Constructs a new
SessionFactory by initialising the object-graph mapping meta-data from the given list of domain
object packages and starts up the Neo4j database in embedded mode. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this session factory
Also closes any underlying resources, like driver etc.
|
void |
deregister(EventListener eventListener)
Removes the the specified listener from
this SessionFactory. |
Driver |
getDriver()
Returns driver used by this SessionFactory
|
LoadStrategy |
getLoadStrategy()
Returns current load strategy
|
MetaData |
metaData()
Retrieves the meta-data that was built up when this
SessionFactory was constructed. |
Session |
openSession()
Opens a new Neo4j mapping
Session using the Driver specified in the OGM baseConfiguration
The driver should be configured to connect to the database using the appropriate
DriverConfig |
void |
register(EventListener eventListener)
Registers the specified listener on all
Session events generated from
this SessionFactory. |
void |
register(IdStrategy strategy)
Register an instance of
IdStrategy
This instance will be used for generation of ids annotated with
@Id @GeneratedValue(strategy=SomeClass.class) |
void |
setLoadStrategy(LoadStrategy loadStrategy)
Sets the LoadStrategy
Will be used for all queries on subsequently created sessions.
|
public SessionFactory(String... packages)
SessionFactory by initialising the object-graph mapping meta-data from the given list of domain
object packages and starts up the Neo4j database in embedded mode. If the embedded driver is not available this method
will throw a Exception.
The package names passed to this constructor should not contain wildcards or trailing full stops, for example, "org.springframework.data.neo4j.example.domain" would be fine. The default behaviour is for sub-packages to be scanned and you can also specify fully-qualified class names if you want to cherry pick particular classes.
Indexes will also be checked or built if configured.packages - The packages to scan for domain objectspublic SessionFactory(Configuration configuration, String... packages)
SessionFactory by initialising the object-graph mapping meta-data from the given list of domain
object packages, and also sets the baseConfiguration to be used.
The package names passed to this constructor should not contain wildcards or trailing full stops, for example, "org.springframework.data.neo4j.example.domain" would be fine. The default behaviour is for sub-packages to be scanned and you can also specify fully-qualified class names if you want to cherry pick particular classes.
Indexes will also be checked or built if configured.configuration - The baseConfiguration to usepackages - The packages to scan for domain objectspublic SessionFactory(Driver driver, String... packages)
driver - driver to be used with this SessionFactorypackages - The packages to scan for domain objectspublic MetaData metaData()
SessionFactory was constructed.MetaDatapublic Session openSession()
Session using the Driver specified in the OGM baseConfiguration
The driver should be configured to connect to the database using the appropriate
DriverConfigSessionpublic void register(EventListener eventListener)
Session events generated from
this SessionFactory.
Only Session instances created after this call are affected.eventListener - The event listener to register.public void deregister(EventListener eventListener)
this SessionFactory.
Only Session instances created after this call are affected.eventListener - The event listener to deregister.public LoadStrategy getLoadStrategy()
public void setLoadStrategy(LoadStrategy loadStrategy)
loadStrategy - load strategypublic Driver getDriver()
public void close()
public void register(IdStrategy strategy)
IdStrategy
This instance will be used for generation of ids annotated with
@Id @GeneratedValue(strategy=SomeClass.class)strategy - IdStrategy to useCopyright © 2018 Neo Technology, Inc.. All rights reserved.