Detailed Description
Session is the primary user interface to the cluster.
Definition at line 26 of file Session.java.
Member Function Documentation
void com.mysql.clusterj.Session.close |
( |
| ) |
|
<T> Query<T> com.mysql.clusterj.Session.createQuery |
( |
QueryDefinition< T > |
qd | ) |
|
Create a Query from a QueryDefinition.
- Parameters
-
- Returns
- the query instance
Transaction com.mysql.clusterj.Session.currentTransaction |
( |
| ) |
|
public<T> void com.mysql.clusterj.Session.deletePersistent |
( |
Class< T > |
cls, |
|
|
Object |
key |
|
) |
| |
Delete an instance of a class from the database given its primary key. For single-column keys, the key parameter is a wrapper (e.g. Integer). For multi-column keys, the key parameter is an Object[] in which elements correspond to the primary keys in order as defined in the schema.
- Parameters
-
cls | the interface or dynamic class |
key | the primary key |
void com.mysql.clusterj.Session.deletePersistent |
( |
Object |
instance | ) |
|
Delete the instance from the database. Only the id field is used to determine which instance is to be deleted. If the instance does not exist in the database, an exception is thrown.
- Parameters
-
instance | the instance to delete |
Implemented in com.mysql.clusterj.core.SessionImpl.
<T> int com.mysql.clusterj.Session.deletePersistentAll |
( |
Class< T > |
cls | ) |
|
Delete all instances of this class from the database. No exception is thrown even if there are no instances in the database.
- Parameters
-
cls | the interface or dynamic class |
- Returns
- the number of instances deleted
void com.mysql.clusterj.Session.deletePersistentAll |
( |
Iterable<?> |
instances | ) |
|
Delete all parameter instances from the database.
- Parameters
-
instances | the instances to delete |
<T> T com.mysql.clusterj.Session.find |
( |
Class< T > |
cls, |
|
|
Object |
key |
|
) |
| |
Find a specific instance by its primary key. The key must be of the same type as the primary key defined by the table corresponding to the cls parameter. The key parameter is the wrapped version of the primitive type of the key, e.g. Integer for INT key types, Long for BIGINT key types, or String for char and varchar types.
For multi-column primary keys, the key parameter is an Object[], each element of which is a component of the primary key. The elements must be in the order of declaration of the columns (not necessarily the order defined in the CONSTRAINT ... PRIMARY KEY clause) of the CREATE TABLE statement.
- Parameters
-
cls | the interface or dynamic class to find an instance of |
key | the key of the instance to find |
- Returns
- the instance of the interface or dynamic class with the specified key
void com.mysql.clusterj.Session.flush |
( |
| ) |
|
Boolean com.mysql.clusterj.Session.found |
( |
Object |
instance | ) |
|
Was the row corresponding to this instance found in the database?
- Parameters
-
instance | the instance corresponding to the row in the database |
- Returns
-
null if the instance is null or was created via newInstance and never loaded;
-
true if the instance was returned from a find or query or created via newInstance and successfully loaded;
-
false if the instance was created via newInstance and not found.
- See Also
- #load(Object)
-
#newInstance(Class, Object)
Implemented in com.mysql.clusterj.core.SessionImpl.
boolean com.mysql.clusterj.Session.isClosed |
( |
| ) |
|
<T> T com.mysql.clusterj.Session.load |
( |
T |
instance | ) |
|
Load the instance from the database into memory. Loading is asynchronous and will be executed when an operation requiring database access is executed: find, flush, or query. The instance must have been returned from find or query; or created via session.newInstance and its primary key initialized.
- Parameters
-
instance | the instance to load |
- Returns
- the instance
- See Also
- found(Object)
<T> T com.mysql.clusterj.Session.makePersistent |
( |
T |
instance | ) |
|
Insert the instance into the database. If the instance already exists in the database, an exception is thrown.
- See Also
- Session::savePersistent(java.lang.Object)
- Parameters
-
instance | the instance to insert |
- Returns
- the instance
Iterable<?> com.mysql.clusterj.Session.makePersistentAll |
( |
Iterable<?> |
instances | ) |
|
Insert the instances into the database.
- Parameters
-
instances | the instances to insert. |
- Returns
- the instances
void com.mysql.clusterj.Session.markModified |
( |
Object |
instance, |
|
|
String |
fieldName |
|
) |
| |
Mark the field in the object as modified so it is flushed.
- Parameters
-
instance | the persistent instance |
fieldName | the field to mark as modified |
Implemented in com.mysql.clusterj.core.SessionImpl.
<T> T com.mysql.clusterj.Session.newInstance |
( |
Class< T > |
cls | ) |
|
Create an instance of an interface or dynamic class that maps to a table.
- Parameters
-
cls | the interface for which to create an instance |
- Returns
- an instance that implements the interface
<T> T com.mysql.clusterj.Session.newInstance |
( |
Class< T > |
cls, |
|
|
Object |
key |
|
) |
| |
Create an instance of an interface or dynamic class that maps to a table and set the primary key of the new instance. The new instance can be used to create, delete, or update a record in the database.
- Parameters
-
cls | the interface for which to create an instance |
- Returns
- an instance that implements the interface
void com.mysql.clusterj.Session.persist |
( |
Object |
instance | ) |
|
Insert the instance into the database. This method has identical semantics to makePersistent.
- Parameters
-
instance | the instance to insert |
Implemented in com.mysql.clusterj.core.SessionImpl.
void com.mysql.clusterj.Session.remove |
( |
Object |
instance | ) |
|
Delete the instance from the database. This method has identical semantics to deletePersistent.
- Parameters
-
instance | the instance to delete |
Implemented in com.mysql.clusterj.core.SessionImpl.
<T> T com.mysql.clusterj.Session.savePersistent |
( |
T |
instance | ) |
|
Save the instance in the database without checking for existence. The id field is used to determine which instance is to be saved. If the instance exists in the database it will be updated. If the instance does not exist, it will be created.
- Parameters
-
instance | the instance to update |
Iterable<?> com.mysql.clusterj.Session.savePersistentAll |
( |
Iterable<?> |
instances | ) |
|
Update all parameter instances in the database.
- Parameters
-
instances | the instances to update |
void com.mysql.clusterj.Session.setLockMode |
( |
LockMode |
lockmode | ) |
|
Set the lock mode for read operations. This will take effect immediately and will remain in effect until this session is closed or this method is called again.
- Parameters
-
Implemented in com.mysql.clusterj.core.SessionImpl.
void com.mysql.clusterj.Session.setPartitionKey |
( |
Class<?> |
cls, |
|
|
Object |
key |
|
) |
| |
Set the partition key for the next transaction. The key must be of the same type as the primary key defined by the table corresponding to the cls parameter. The key parameter is the wrapped version of the primitive type of the key, e.g. Integer for INT key types, Long for BIGINT key types, or String for char and varchar types.
For multi-column primary keys, the key parameter is an Object[], each element of which is a component of the primary key. The elements must be in the order of declaration of the columns (not necessarily the order defined in the CONSTRAINT ... PRIMARY KEY clause) of the CREATE TABLE statement.
- Exceptions
-
- Parameters
-
key | the primary key of the mapped table |
Implemented in com.mysql.clusterj.core.SessionImpl.
void com.mysql.clusterj.Session.updatePersistent |
( |
Object |
instance | ) |
|
Update the instance in the database without necessarily retrieving it. The id field is used to determine which instance is to be updated. If the instance does not exist in the database, an exception is thrown. This method cannot be used to change the primary key.
- Parameters
-
instance | the instance to update |
Implemented in com.mysql.clusterj.core.SessionImpl.
void com.mysql.clusterj.Session.updatePersistentAll |
( |
Iterable<?> |
instances | ) |
|
Update all parameter instances in the database.
- Parameters
-
instances | the instances to update |
The documentation for this interface was generated from the following file:
- storage/ndb/clusterj/clusterj-api/src/main/java/com/mysql/clusterj/Session.java