MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mysql.clusterj.Session Interface Reference
Inheritance diagram for com.mysql.clusterj.Session:

Public Member Functions

QueryBuilder getQueryBuilder ()
< T > Query< T > createQuery (QueryDefinition< T > qd)
< T > T find (Class< T > cls, Object key)
< T > T newInstance (Class< T > cls)
< T > T newInstance (Class< T > cls, Object key)
< T > T makePersistent (T instance)
< T > T load (T instance)
Boolean found (Object instance)
void persist (Object instance)
Iterable<?> makePersistentAll (Iterable<?> instances)
public< T > void deletePersistent (Class< T > cls, Object key)
void deletePersistent (Object instance)
void remove (Object instance)
< T > int deletePersistentAll (Class< T > cls)
void deletePersistentAll (Iterable<?> instances)
void updatePersistent (Object instance)
void updatePersistentAll (Iterable<?> instances)
< T > T savePersistent (T instance)
Iterable<?> savePersistentAll (Iterable<?> instances)
Transaction currentTransaction ()
void close ()
boolean isClosed ()
void flush ()
void setPartitionKey (Class<?> cls, Object key)
void setLockMode (LockMode lockmode)
void markModified (Object instance, String fieldName)

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 ( )

Close this session.

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

<T> Query<T> com.mysql.clusterj.Session.createQuery ( QueryDefinition< T >  qd)

Create a Query from a QueryDefinition.

Parameters
qdthe query definition
Returns
the query instance

Here is the caller graph for this function:

Transaction com.mysql.clusterj.Session.currentTransaction ( )

Get the current Transaction.

Returns
the transaction

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

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
clsthe interface or dynamic class
keythe primary key

Here is the caller graph for this function:

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
instancethe 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
clsthe interface or dynamic class
Returns
the number of instances deleted

Here is the caller graph for this function:

void com.mysql.clusterj.Session.deletePersistentAll ( Iterable<?>  instances)

Delete all parameter instances from the database.

Parameters
instancesthe 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
clsthe interface or dynamic class to find an instance of
keythe key of the instance to find
Returns
the instance of the interface or dynamic class with the specified key

Here is the caller graph for this function:

void com.mysql.clusterj.Session.flush ( )

Flush deferred changes to the back end. Inserts, deletes, loads, and updates are sent to the back end.

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

Boolean com.mysql.clusterj.Session.found ( Object  instance)

Was the row corresponding to this instance found in the database?

Parameters
instancethe 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.

QueryBuilder com.mysql.clusterj.Session.getQueryBuilder ( )

Get a QueryBuilder.

Returns
the query builder

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

boolean com.mysql.clusterj.Session.isClosed ( )

Is this session closed?

Returns
true if the session is closed

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

<T> T com.mysql.clusterj.Session.load ( 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
instancethe instance to load
Returns
the instance
See Also
found(Object)
<T> T com.mysql.clusterj.Session.makePersistent ( 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
instancethe instance to insert
Returns
the instance

Here is the caller graph for this function:

Iterable<?> com.mysql.clusterj.Session.makePersistentAll ( Iterable<?>  instances)

Insert the instances into the database.

Parameters
instancesthe instances to insert.
Returns
the instances

Here is the caller graph for this function:

void com.mysql.clusterj.Session.markModified ( Object  instance,
String  fieldName 
)

Mark the field in the object as modified so it is flushed.

Parameters
instancethe persistent instance
fieldNamethe 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
clsthe interface for which to create an instance
Returns
an instance that implements the interface

Here is the caller graph for this function:

<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
clsthe 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
instancethe instance to insert

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

void com.mysql.clusterj.Session.remove ( Object  instance)

Delete the instance from the database. This method has identical semantics to deletePersistent.

Parameters
instancethe instance to delete

Implemented in com.mysql.clusterj.core.SessionImpl.

<T> T com.mysql.clusterj.Session.savePersistent ( 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
instancethe instance to update
Iterable<?> com.mysql.clusterj.Session.savePersistentAll ( Iterable<?>  instances)

Update all parameter instances in the database.

Parameters
instancesthe 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
lockmodethe LockMode

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
ClusterJUserExceptionif a transaction is enlisted
ClusterJUserExceptionif a partition key is null
ClusterJUserExceptionif called twice in the same transaction
ClusterJUserExceptionif a partition key is the wrong type
Parameters
keythe 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
instancethe instance to update

Implemented in com.mysql.clusterj.core.SessionImpl.

Here is the caller graph for this function:

void com.mysql.clusterj.Session.updatePersistentAll ( Iterable<?>  instances)

Update all parameter instances in the database.

Parameters
instancesthe instances to update

Here is the caller graph for this function:


The documentation for this interface was generated from the following file: